2
* Copyright (c) 1990 - 1994, Julianne Frances Haugh
3
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
4
* Copyright (c) 2003 - 2006, Tomasz Kłoczko
5
* Copyright (c) 2007 - 2009, Nicolas François
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* 3. The name of the copyright holders or contributors may not be used to
17
* endorse or promote products derived from this software without
18
* specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4
36
* prototypes of libmisc functions, and private lib functions.
6
* $Id: prototypes.h 1902 2008-03-17 23:04:46Z nekral-guest $
38
* $Id: prototypes.h 2650 2009-04-11 18:37:08Z nekral-guest $
24
57
#include "defines.h"
25
58
#include "commonio.h"
63
#if defined (HAVE_SETGROUPS) && ! defined (USE_PAM)
28
64
extern int add_groups (const char *);
29
extern void add_cons_grps (void);
32
extern void agecheck (const struct passwd *, const struct spwd *);
68
extern void agecheck (const struct spwd *);
33
69
extern int expire (const struct passwd *, const struct spwd *);
34
70
extern int isexpired (const struct passwd *, const struct spwd *);
41
77
extern int chown_tree (const char *, uid_t, uid_t, gid_t, gid_t);
44
extern void chown_tty (const char *, const struct passwd *);
80
extern void chown_tty (const struct passwd *);
83
typedef void (*cleanup_function) (void *arg);
84
void add_cleanup (cleanup_function pcf, void *arg);
85
void del_cleanup (cleanup_function pcf);
86
void do_cleanups (void);
89
struct cleanup_info_mod {
94
void cleanup_report_add_group (void *group_name);
95
void cleanup_report_add_group_group (void *group_name);
97
void cleanup_report_add_group_gshadow (void *group_name);
99
void cleanup_report_del_group (void *group_name);
100
void cleanup_report_del_group_group (void *group_name);
102
void cleanup_report_del_group_gshadow (void *group_name);
104
void cleanup_report_mod_passwd (void *cleanup_info);
105
void cleanup_report_mod_group (void *cleanup_info);
106
void cleanup_report_mod_gshadow (void *cleanup_info);
107
void cleanup_unlock_group (void *unused);
109
void cleanup_unlock_gshadow (void *unused);
111
void cleanup_unlock_passwd (void *unused);
47
extern int console (const char *);
114
extern bool console (const char *);
50
117
extern int copy_tree (const char *src_root, const char *dst_root,
51
118
long int uid, long int gid);
52
119
extern int remove_tree (const char *root);
122
extern int selinux_file_context (const char *dst_name);
55
126
extern char *pw_encrypt (const char *, const char *);
67
138
extern void change_field (char *, size_t, const char *);
68
139
extern int valid_field (const char *, const char *);
71
extern int find_new_uid (int sys_user, uid_t *uid, uid_t const *preferred_uid);
72
extern int find_new_gid (int sys_group, gid_t *gid, gid_t const *preferred_gid);
142
extern int find_new_gid (bool sys_group, gid_t *gid, gid_t const *preferred_gid);
145
extern int find_new_uid (bool sys_user, uid_t *uid, uid_t const *preferred_uid);
148
extern int get_gid (const char *gidstr, gid_t *gid);
150
/* getgr_nam_gid.c */
151
extern struct group *getgr_nam_gid (const char *grname);
75
extern int getlong(const char *numstr, long int *result);
154
extern int getlong (const char *numstr, long int *result);
157
extern int getrange (char *range,
158
unsigned long *min, bool *has_min,
159
unsigned long *max, bool *has_max);
162
extern int get_uid (const char *uidstr, uid_t *uid);
78
165
extern char *fgetsx (char *, int, FILE *);
88
175
extern struct group *__gr_dup (const struct group *grent);
91
extern int hushed (const struct passwd *);
178
extern bool hushed (const struct passwd *pw);
93
180
/* audit_help.c */
95
182
extern int audit_fd;
96
183
extern void audit_help_open (void);
184
/* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */
185
#define AUDIT_NO_ID ((unsigned int) -1)
187
SHADOW_AUDIT_FAILURE = 0,
188
SHADOW_AUDIT_SUCCESS = 1} shadow_audit_result;
97
189
extern void audit_logger (int type, const char *pgname, const char *op,
98
const char *name, unsigned int id, int result);
190
const char *name, unsigned int id,
191
shadow_audit_result result);
192
void audit_logger_message (const char *message, shadow_audit_result result);
102
197
extern void setup_limits (const struct passwd *);
105
201
extern char **add_list (char **, const char *);
106
202
extern char **del_list (char **, const char *);
107
203
extern char **dup_list (char *const *);
108
extern int is_on_list (char *const *, const char *);
204
extern bool is_on_list (char *const *list, const char *member);
109
205
extern char **comma_to_list (const char *);
130
226
extern struct passwd *get_my_pwent (void);
133
230
extern int obscure (const char *, const char *, const struct passwd *);
136
extern void do_pam_passwd (const char *, int, int);
235
extern void do_pam_passwd (const char *user, bool silent, bool change_expired);
139
extern int isttytime (const char *, const char *, time_t);
239
extern bool isttytime (const char *, const char *, time_t);
142
243
extern struct spwd *pwd_to_spwd (const struct passwd *);
145
248
extern void passwd_check (const char *, const char *, const char *);
148
252
extern void pwd_init (void);
156
260
extern struct passwd *__pw_dup (const struct passwd *pwent);
159
extern int do_rlogin (const char *, char *, int, char *, int);
263
extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
264
char *term, size_t termlen);
162
267
extern char *crypt_make_salt (const char *meth, void *arg);
165
extern int setup_groups (const struct passwd *);
166
extern int change_uid (const struct passwd *);
167
extern int setup_uid_gid (const struct passwd *, int);
270
extern int setup_groups (const struct passwd *info);
271
extern int change_uid (const struct passwd *info);
272
#if (defined HAVE_INITGROUPS) && (! defined USE_PAM)
273
extern int setup_uid_gid (const struct passwd *info, bool is_console);
275
extern int setup_uid_gid (const struct passwd *info);
170
279
extern void setup (struct passwd *);
201
321
extern int check_su_auth (const char *actual_id, const char *wanted_id);
204
extern void sulog (const char *, int, const char *, const char *);
324
extern void sulog (const char *tty,
207
330
extern void subsystem (const struct passwd *);
210
333
extern void ttytype (const char *);
213
337
extern char *tz (const char *);
216
extern void set_filesize_limit (int);
341
extern int set_filesize_limit (int blocks);
219
extern void checkutmp (int);
220
extern void setutmp (const char *, const char *, const char *);
344
extern void checkutmp (bool picky);
345
extern int setutmp (const char *, const char *, const char *);
223
extern int valid (const char *, const struct passwd *);
348
extern bool valid (const char *, const struct passwd *);
226
351
extern char *xmalloc (size_t);