forked from vyos/libnss-mapuser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_common.h
67 lines (61 loc) · 2.08 KB
/
map_common.h
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
62
63
64
65
66
67
/*
* Copyright (C) 2017 Cumulus Networks, Inc.
* All rights reserved.
* Author: Dave Olson <[email protected]>
*
* 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 map_min_uid;
extern int map_debug;
extern int nss_mapuser_config(int *errnop, const char *lname);
extern uint32_t get_sessionid(void);
extern int skip_program(void);
extern int find_mappingfile(struct pwbuf *pb, uid_t uid);
extern int find_mapped_name(struct pwbuf *pb, uid_t uid, uint32_t session);
extern int make_mapuser(struct pwbuf *pb, const char *name);
extern int map_init_common(int *errnop, const char *plugname);
extern char **fixup_gr_mem(const char *name, const char **gr_in, char *buf,
size_t * lp, int *err, unsigned privbits);
extern void cleanup_gr_mem(void);
#define PRIV_MATCH 2
#define UNPRIV_MATCH 1