summaryrefslogtreecommitdiff
path: root/map_common.h
blob: ff136d3cc94ef71d7809ec9782aeb39dc02b5ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (C) 2017 Cumulus Networks, Inc.
 * All rights reserved.
 * Author: Dave Olson <olson@cumulusnetworks.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program - see the file COPYING.
 */

/*
 * This is the header file for the common code used by the nss_mapuser and
 * nss_mapuid NSS plugin library.   None of it's symbols are public, they are
 * stripped during the linking phase (made internal only).
 */


#include <string.h>
#include <syslog.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <pwd.h>
#include <errno.h>
#include <ctype.h>
#include <nss.h>


/*
 * pwbuf is used to reduce number of arguments passed around; the strings in
 * the passwd struct need to point into this buffer.
 */
struct pwbuf {
    char *name;
    char *buf;
    struct passwd *pw;
    int *errnop;
    size_t buflen;
};

/* configuration variables. */
extern char *exclude_users;
extern char *mappeduser;
extern char *mapped_priv_user;
extern uid_t min_uid;
extern int debug;

extern int nss_mapuser_config(int *errnop, const char *lname);
extern int pwcopy(char *buf, size_t len, struct passwd *srcpw, struct passwd *destpw,
       const char *usename);
extern int get_pw_mapuser(const char *name, struct pwbuf *pb);