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.
36 * prototypes of libmisc functions, and private lib functions.
51 #include <sys/types.h>
63 #if defined (HAVE_SETGROUPS) && ! defined (USE_PAM)
64 extern int add_groups (const char *);
68 extern void agecheck (/*@null@*/const struct spwd *);
69 extern int expire (const struct passwd *, /*@null@*/const struct spwd *);
71 extern int isexpired (const struct passwd *, /*@null@*/const struct spwd *);
73 /* basename() renamed to Basename() to avoid libc name space confusion */
75 extern char *Basename (char *str);
78 extern int chown_tree (const char *, uid_t, uid_t, gid_t, gid_t);
81 extern void chown_tty (const struct passwd *);
84 typedef void (*cleanup_function) (/*@null@*/void *arg);
85 void add_cleanup (cleanup_function pcf, /*@null@*/void *arg);
86 void del_cleanup (cleanup_function pcf);
87 void do_cleanups (void);
90 struct cleanup_info_mod {
95 void cleanup_report_add_group (void *group_name);
96 void cleanup_report_add_group_group (void *group_name);
98 void cleanup_report_add_group_gshadow (void *group_name);
100 void cleanup_report_del_group (void *group_name);
101 void cleanup_report_del_group_group (void *group_name);
103 void cleanup_report_del_group_gshadow (void *group_name);
105 void cleanup_report_mod_passwd (void *cleanup_info);
106 void cleanup_report_mod_group (void *cleanup_info);
107 void cleanup_report_mod_gshadow (void *cleanup_info);
108 void cleanup_unlock_group (/*@null@*/void *unused);
110 void cleanup_unlock_gshadow (/*@null@*/void *unused);
112 void cleanup_unlock_passwd (/*@null@*/void *unused);
115 extern bool console (const char *);
118 extern int copy_tree (const char *src_root, const char *dst_root,
119 long int uid, long int gid);
120 extern int remove_tree (const char *root);
123 extern int selinux_file_context (const char *dst_name);
127 extern char *pw_encrypt (const char *, const char *);
130 extern void pw_entry (const char *, struct passwd *);
133 extern void addenv (const char *, /*@null@*/const char *);
134 extern void initenv (void);
135 extern void set_env (int, char *const *);
136 extern void sanitize_env (void);
139 extern void change_field (char *, size_t, const char *);
140 extern int valid_field (const char *, const char *);
143 extern int find_new_gid (bool sys_group,
145 /*@null@*/gid_t const *preferred_gid);
148 extern int find_new_uid (bool sys_user,
150 /*@null@*/uid_t const *preferred_uid);
153 extern int get_gid (const char *gidstr, gid_t *gid);
155 /* getgr_nam_gid.c */
156 extern /*@null@*/struct group *getgr_nam_gid (const char *grname);
159 extern int getlong (const char *numstr, /*@out@*/long int *result);
162 extern int getrange (char *range,
163 unsigned long *min, bool *has_min,
164 unsigned long *max, bool *has_max);
167 extern int get_uid (const char *uidstr, uid_t *uid);
170 extern /*@null@*/char *fgetsx (/*@returned@*/ /*@out@*/char *, int, FILE *);
171 extern int fputsx (const char *, FILE *);
174 extern void __gr_del_entry (const struct commonio_entry *ent);
175 extern struct commonio_db *__gr_get_db (void);
176 extern /*@null@*/struct commonio_entry *__gr_get_head (void);
177 extern void __gr_set_changed (void);
180 extern /*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent);
181 extern void gr_free (/*@out@*/ /*@only@*/struct group *grent);
184 extern bool hushed (const char *username);
189 extern void audit_help_open (void);
190 /* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */
191 #define AUDIT_NO_ID ((unsigned int) -1)
193 SHADOW_AUDIT_FAILURE = 0,
194 SHADOW_AUDIT_SUCCESS = 1} shadow_audit_result;
195 extern void audit_logger (int type, const char *pgname, const char *op,
196 const char *name, unsigned int id,
197 shadow_audit_result result);
198 void audit_logger_message (const char *message, shadow_audit_result result);
203 extern void setup_limits (const struct passwd *);
207 extern /*@only@*/ /*@out@*/char **add_list (/*@returned@*/ /*@only@*/char **, const char *);
208 extern /*@only@*/ /*@out@*/char **del_list (/*@returned@*/ /*@only@*/char **, const char *);
209 extern /*@only@*/ /*@out@*/char **dup_list (char *const *);
210 extern bool is_on_list (char *const *list, const char *member);
211 extern /*@only@*/char **comma_to_list (const char *);
214 extern void dolastlog (struct lastlog *ll,
215 const struct passwd *pw,
220 extern int login_access (const char *user, const char *from);
223 extern void login_prompt (const char *, char *, int);
226 extern void mailcheck (void);
229 extern void motd (void);
232 extern /*@null@*/struct passwd *get_my_pwent (void);
236 extern int obscure (const char *, const char *, const struct passwd *);
241 extern void do_pam_passwd (const char *user, bool silent, bool change_expired);
245 extern bool isttytime (const char *, const char *, time_t);
249 extern struct spwd *pwd_to_spwd (const struct passwd *);
254 extern void passwd_check (const char *, const char *, const char *);
258 extern void pwd_init (void);
261 extern void __pw_del_entry (const struct commonio_entry *ent);
262 extern struct commonio_db *__pw_get_db (void);
263 extern /*@null@*/struct commonio_entry *__pw_get_head (void);
266 extern /*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent);
267 extern void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent);
270 extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
271 char *term, size_t termlen);
274 extern /*@observer@*/const char *crypt_make_salt (/*@null@*/const char *meth, /*@null@*/void *arg);
277 extern int setup_groups (const struct passwd *info);
278 extern int change_uid (const struct passwd *info);
279 #if (defined HAVE_INITGROUPS) && (! defined USE_PAM)
280 extern int setup_uid_gid (const struct passwd *info, bool is_console);
282 extern int setup_uid_gid (const struct passwd *info);
286 extern void setup (struct passwd *);
289 extern void setup_env (struct passwd *);
292 extern struct group *sgetgrent (const char *buf);
295 extern struct passwd *sgetpwent (const char *buf);
298 #ifndef HAVE_SGETSPENT
299 extern struct spwd *sgetspent (const char *string);
303 extern void __sgr_del_entry (const struct commonio_entry *ent);
304 extern /*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent);
305 extern void sgr_free (/*@out@*/ /*@only@*/struct sgrp *sgent);
306 extern /*@null@*/struct commonio_entry *__sgr_get_head (void);
307 extern void __sgr_set_changed (void);
310 extern /*@null@*/struct commonio_entry *__spw_get_head (void);
311 extern void __spw_del_entry (const struct commonio_entry *ent);
314 extern /*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent);
315 extern void spw_free (/*@out@*/ /*@only@*/struct spwd *spent);
318 extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[]);
321 extern int safe_system (const char *command,
327 extern long strtoday (const char *);
330 extern int check_su_auth (const char *actual_id, const char *wanted_id);
333 extern void sulog (const char *tty,
339 extern void subsystem (const struct passwd *);
342 extern void ttytype (const char *);
346 extern char *tz (const char *);
350 extern int set_filesize_limit (int blocks);
353 extern /*@null@*/struct utmp *get_current_utmp (void);
354 extern struct utmp *prepare_utmp (const char *name,
357 /*@null@*/const struct utmp *ut);
358 extern int setutmp (struct utmp *ut);
360 extern struct utmpx *prepare_utmpx (const char *name,
363 /*@null@*/const struct utmp *ut);
364 extern int setutmpx (struct utmpx *utx);
368 extern bool valid (const char *, const struct passwd *);
371 extern /*@maynotreturn@*/ /*@only@*/char *xmalloc (size_t);
372 extern /*@maynotreturn@*/ /*@only@*/char *xstrdup (const char *);
375 extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *);
377 extern /*@null@*/ /*@only@*/struct passwd *xgetpwuid (uid_t);
379 extern /*@null@*/ /*@only@*/struct group *xgetgrnam (const char *);
381 extern /*@null@*/ /*@only@*/struct group *xgetgrgid (gid_t);
383 extern /*@null@*/ /*@only@*/struct spwd *xgetspnam(const char *);
386 extern bool yes_or_no (bool read_only);
388 #endif /* _PROTOTYPES_H */