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.
38 * $Id: prototypes.h 2935 2009-05-18 18:32:17Z nekral-guest $
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 get_pid (const char *pidstr, pid_t *pid);
165 extern int getrange (char *range,
166 unsigned long *min, bool *has_min,
167 unsigned long *max, bool *has_max);
170 extern int get_uid (const char *uidstr, uid_t *uid);
173 extern int getulong (const char *numstr, /*@out@*/unsigned long int *result);
176 extern /*@null@*/char *fgetsx (/*@returned@*/ /*@out@*/char *, int, FILE *);
177 extern int fputsx (const char *, FILE *);
180 extern void __gr_del_entry (const struct commonio_entry *ent);
181 extern /*@observer@*/const struct commonio_db *__gr_get_db (void);
182 extern /*@dependent@*/ /*@null@*/struct commonio_entry *__gr_get_head (void);
183 extern void __gr_set_changed (void);
186 extern /*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent);
187 extern void gr_free (/*@out@*/ /*@only@*/struct group *grent);
190 extern bool hushed (const char *username);
195 extern void audit_help_open (void);
196 /* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */
197 #define AUDIT_NO_ID ((unsigned int) -1)
199 SHADOW_AUDIT_FAILURE = 0,
200 SHADOW_AUDIT_SUCCESS = 1} shadow_audit_result;
201 extern void audit_logger (int type, const char *pgname, const char *op,
202 const char *name, unsigned int id,
203 shadow_audit_result result);
204 void audit_logger_message (const char *message, shadow_audit_result result);
209 extern void setup_limits (const struct passwd *);
213 extern /*@only@*/ /*@out@*/char **add_list (/*@returned@*/ /*@only@*/char **, const char *);
214 extern /*@only@*/ /*@out@*/char **del_list (/*@returned@*/ /*@only@*/char **, const char *);
215 extern /*@only@*/ /*@out@*/char **dup_list (char *const *);
216 extern bool is_on_list (char *const *list, const char *member);
217 extern /*@only@*/char **comma_to_list (const char *);
220 extern void dolastlog (
222 const struct passwd *pw,
223 /*@unique@*/const char *line,
224 /*@unique@*/const char *host);
227 extern int login_access (const char *user, const char *from);
230 extern void login_prompt (const char *, char *, int);
233 extern void mailcheck (void);
236 extern void motd (void);
239 extern /*@null@*/struct passwd *get_my_pwent (void);
241 /* pam_pass_non_interractive.c */
243 extern int do_pam_passwd_non_interractive (const char *pam_service,
244 const char *username,
245 const char* password);
250 extern int obscure (const char *, const char *, const struct passwd *);
255 extern void do_pam_passwd (const char *user, bool silent, bool change_expired);
259 extern bool isttytime (const char *, const char *, time_t);
263 extern struct spwd *pwd_to_spwd (const struct passwd *);
268 extern void passwd_check (const char *, const char *, const char *);
272 extern void pwd_init (void);
275 extern void __pw_del_entry (const struct commonio_entry *ent);
276 extern struct commonio_db *__pw_get_db (void);
277 extern /*@dependent@*/ /*@null@*/struct commonio_entry *__pw_get_head (void);
280 extern /*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent);
281 extern void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent);
284 extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
285 char *term, size_t termlen);
288 extern /*@observer@*/const char *crypt_make_salt (/*@null@*/const char *meth, /*@null@*/void *arg);
291 extern int setup_groups (const struct passwd *info);
292 extern int change_uid (const struct passwd *info);
293 #if (defined HAVE_INITGROUPS) && (! defined USE_PAM)
294 extern int setup_uid_gid (const struct passwd *info, bool is_console);
296 extern int setup_uid_gid (const struct passwd *info);
300 extern void setup (struct passwd *);
303 extern void setup_env (struct passwd *);
306 extern struct group *sgetgrent (const char *buf);
309 extern struct passwd *sgetpwent (const char *buf);
312 #ifndef HAVE_SGETSPENT
313 extern struct spwd *sgetspent (const char *string);
317 extern void __sgr_del_entry (const struct commonio_entry *ent);
318 extern /*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent);
319 extern void sgr_free (/*@out@*/ /*@only@*/struct sgrp *sgent);
320 extern /*@dependent@*/ /*@null@*/struct commonio_entry *__sgr_get_head (void);
321 extern void __sgr_set_changed (void);
324 extern /*@dependent@*/ /*@null@*/struct commonio_entry *__spw_get_head (void);
325 extern void __spw_del_entry (const struct commonio_entry *ent);
328 extern /*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent);
329 extern void spw_free (/*@out@*/ /*@only@*/struct spwd *spent);
332 extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[]);
335 extern int safe_system (const char *command,
341 extern long strtoday (const char *);
344 extern int check_su_auth (const char *actual_id, const char *wanted_id);
347 extern void sulog (const char *tty,
353 extern void subsystem (const struct passwd *);
356 extern void ttytype (const char *);
360 extern char *tz (const char *);
364 extern int set_filesize_limit (int blocks);
367 extern int user_busy (const char *name, uid_t uid);
370 extern /*@null@*/struct utmp *get_current_utmp (void);
371 extern struct utmp *prepare_utmp (const char *name,
374 /*@null@*/const struct utmp *ut);
375 extern int setutmp (struct utmp *ut);
377 extern struct utmpx *prepare_utmpx (const char *name,
380 /*@null@*/const struct utmp *ut);
381 extern int setutmpx (struct utmpx *utx);
382 #endif /* USE_UTMPX */
385 extern bool valid (const char *, const struct passwd *);
388 extern /*@maynotreturn@*/ /*@out@*//*@only@*/char *xmalloc (size_t size)
389 /*@ensures MaxSet(result) == (size - 1); @*/;
390 extern /*@maynotreturn@*/ /*@only@*/char *xstrdup (const char *);
393 extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *);
395 extern /*@null@*/ /*@only@*/struct passwd *xgetpwuid (uid_t);
397 extern /*@null@*/ /*@only@*/struct group *xgetgrnam (const char *);
399 extern /*@null@*/ /*@only@*/struct group *xgetgrgid (gid_t);
401 extern /*@null@*/ /*@only@*/struct spwd *xgetspnam(const char *);
404 extern bool yes_or_no (bool read_only);
406 #endif /* _PROTOTYPES_H */