]> granicus.if.org Git - shadow/blob - lib/prototypes.h
* libmisc/find_new_gid.c, libmisc/find_new_uid.c,
[shadow] / lib / prototypes.h
1 /*
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
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
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.
19  *
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.
31  */
32
33 /*
34  * prototypes.h
35  *
36  * prototypes of libmisc functions, and private lib functions.
37  *
38  * $Id$
39  *
40  */
41
42 #ifndef _PROTOTYPES_H
43 #define _PROTOTYPES_H
44
45 #include <sys/stat.h>
46 #if HAVE_UTMPX_H
47 #include <utmpx.h>
48 #else
49 #include <utmp.h>
50 #endif
51 #include <sys/types.h>
52 #include <pwd.h>
53 #include <grp.h>
54 #include <shadow.h>
55 #include <lastlog.h>
56
57 #include "defines.h"
58 #include "commonio.h"
59
60 extern char *Prog;
61
62 /* addgrps.c */
63 #if defined (HAVE_SETGROUPS) && ! defined (USE_PAM)
64 extern int add_groups (const char *);
65 #endif
66
67 /* age.c */
68 extern void agecheck (/*@null@*/const struct spwd *);
69 extern int expire (const struct passwd *, /*@null@*/const struct spwd *);
70 /* isexpired.c */
71 extern int isexpired (const struct passwd *, /*@null@*/const struct spwd *);
72
73 /* basename() renamed to Basename() to avoid libc name space confusion */
74 /* basename.c */
75 extern char *Basename (char *str);
76
77 /* chowndir.c */
78 extern int chown_tree (const char *, uid_t, uid_t, gid_t, gid_t);
79
80 /* chowntty.c */
81 extern void chown_tty (const struct passwd *);
82
83 /* cleanup.c */
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);
88
89 /* cleanup_group.c */
90 struct cleanup_info_mod {
91         char *audit_msg;
92         char *action;
93         char *name;
94 };
95 void cleanup_report_add_group (void *group_name);
96 void cleanup_report_add_group_group (void *group_name);
97 #ifdef SHADOWGRP
98 void cleanup_report_add_group_gshadow (void *group_name);
99 #endif
100 void cleanup_report_del_group (void *group_name);
101 void cleanup_report_del_group_group (void *group_name);
102 #ifdef SHADOWGRP
103 void cleanup_report_del_group_gshadow (void *group_name);
104 #endif
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);
109 #ifdef SHADOWGRP
110 void cleanup_unlock_gshadow (/*@null@*/void *unused);
111 #endif
112 void cleanup_unlock_passwd (/*@null@*/void *unused);
113
114 /* console.c */
115 extern bool console (const char *);
116
117 /* copydir.c */
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);
121
122 #ifdef WITH_SELINUX
123 extern int selinux_file_context (const char *dst_name);
124 #endif
125
126 /* encrypt.c */
127 extern char *pw_encrypt (const char *, const char *);
128
129 /* entry.c */
130 extern void pw_entry (const char *, struct passwd *);
131
132 /* env.c */
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);
137
138 /* fields.c */
139 extern void change_field (char *, size_t, const char *);
140 extern int valid_field (const char *, const char *);
141
142 /* find_new_gid.c */
143 extern int find_new_gid (bool sys_group,
144                          gid_t *gid,
145                          /*@null@*/gid_t const *preferred_gid);
146
147 /* find_new_uid.c */
148 extern int find_new_uid (bool sys_user,
149                          uid_t *uid,
150                          /*@null@*/uid_t const *preferred_uid);
151
152 /* get_gid.c */
153 extern int get_gid (const char *gidstr, gid_t *gid);
154
155 /* getgr_nam_gid.c */
156 extern /*@null@*/struct group *getgr_nam_gid (const char *grname);
157
158 /* getlong.c */
159 extern int getlong (const char *numstr, /*@out@*/long int *result);
160
161 /* getrange */
162 extern int getrange (char *range,
163                      unsigned long *min, bool *has_min,
164                      unsigned long *max, bool *has_max);
165
166 /* get_uid.c */
167 extern int get_uid (const char *uidstr, uid_t *uid);
168
169 /* fputsx.c */
170 extern /*@null@*/char *fgetsx (/*@returned@*/ /*@out@*/char *, int, FILE *);
171 extern int fputsx (const char *, FILE *);
172
173 /* groupio.c */
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);
178
179 /* groupmem.c */
180 extern /*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent);
181 extern void gr_free (/*@out@*/ /*@only@*/struct group *grent);
182
183 /* hushed.c */
184 extern bool hushed (const char *username);
185
186 /* audit_help.c */
187 #ifdef WITH_AUDIT
188 extern int audit_fd;
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)
192 typedef enum {
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);
199 #endif
200
201 /* limits.c */
202 #ifndef USE_PAM
203 extern void setup_limits (const struct passwd *);
204 #endif
205
206 /* list.c */
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 *);
212
213 /* log.c */
214 extern void dolastlog (struct lastlog *ll,
215                        const struct passwd *pw,
216                        const char *line,
217                        const char *host);
218
219 /* login_nopam.c */
220 extern int login_access (const char *user, const char *from);
221
222 /* loginprompt.c */
223 extern void login_prompt (const char *, char *, int);
224
225 /* mail.c */
226 extern void mailcheck (void);
227
228 /* motd.c */
229 extern void motd (void);
230
231 /* myname.c */
232 extern /*@null@*/struct passwd *get_my_pwent (void);
233
234 /* obscure.c */
235 #ifndef USE_PAM
236 extern int obscure (const char *, const char *, const struct passwd *);
237 #endif
238
239 /* pam_pass.c */
240 #ifdef USE_PAM
241 extern void do_pam_passwd (const char *user, bool silent, bool change_expired);
242 #endif
243
244 /* port.c */
245 extern bool isttytime (const char *, const char *, time_t);
246
247 /* pwd2spwd.c */
248 #ifndef USE_PAM
249 extern struct spwd *pwd_to_spwd (const struct passwd *);
250 #endif
251
252 /* pwdcheck.c */
253 #ifndef USE_PAM
254 extern void passwd_check (const char *, const char *, const char *);
255 #endif
256
257 /* pwd_init.c */
258 extern void pwd_init (void);
259
260 /* pwio.c */
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);
264
265 /* pwmem.c */
266 extern /*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent);
267 extern void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent);
268
269 /* rlogin.c */
270 extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
271                       char *term, size_t termlen);
272
273 /* salt.c */
274 extern /*@observer@*/const char *crypt_make_salt (/*@null@*/const char *meth, /*@null@*/void *arg);
275
276 /* setugid.c */
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);
281 #else
282 extern int setup_uid_gid (const struct passwd *info);
283 #endif
284
285 /* setup.c */
286 extern void setup (struct passwd *);
287
288 /* setupenv.c */
289 extern void setup_env (struct passwd *);
290
291 /* sgetgrent.c */
292 extern struct group *sgetgrent (const char *buf);
293
294 /* sgetpwent.c */
295 extern struct passwd *sgetpwent (const char *buf);
296
297 /* sgetspent.c */
298 #ifndef HAVE_SGETSPENT
299 extern struct spwd *sgetspent (const char *string);
300 #endif
301
302 /* sgroupio.c */
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);
308
309 /* shadowio.c */
310 extern /*@null@*/struct commonio_entry *__spw_get_head (void);
311 extern void __spw_del_entry (const struct commonio_entry *ent);
312
313 /* shadowmem.c */
314 extern /*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent);
315 extern void spw_free (/*@out@*/ /*@only@*/struct spwd *spent);
316
317 /* shell.c */
318 extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[]);
319
320 /* system.c */
321 extern int safe_system (const char *command,
322                         const char *argv[],
323                         const char *env[],
324                         int ignore_stderr);
325
326 /* strtoday.c */
327 extern long strtoday (const char *);
328
329 /* suauth.c */
330 extern int check_su_auth (const char *actual_id, const char *wanted_id);
331
332 /* sulog.c */
333 extern void sulog (const char *tty,
334                    bool success,
335                    const char *oldname,
336                    const char *name);
337
338 /* sub.c */
339 extern void subsystem (const struct passwd *);
340
341 /* ttytype.c */
342 extern void ttytype (const char *);
343
344 /* tz.c */
345 #ifndef USE_PAM
346 extern char *tz (const char *);
347 #endif
348
349 /* ulimit.c */
350 extern int set_filesize_limit (int blocks);
351
352 /* utmp.c */
353 extern /*@null@*/struct utmp *get_current_utmp (void);
354 extern struct utmp *prepare_utmp (const char *name,
355                                   const char *line,
356                                   const char *host,
357                                   /*@null@*/const struct utmp *ut);
358 extern int setutmp (struct utmp *ut);
359 #ifdef HAVE_UTMPX_H
360 extern struct utmpx *prepare_utmpx (const char *name,
361                                     const char *line,
362                                     const char *host,
363                                     /*@null@*/const struct utmp *ut);
364 extern int setutmpx (struct utmpx *utx);
365 #endif
366
367 /* valid.c */
368 extern bool valid (const char *, const struct passwd *);
369
370 /* xmalloc.c */
371 extern /*@maynotreturn@*/ /*@only@*/char *xmalloc (size_t);
372 extern /*@maynotreturn@*/ /*@only@*/char *xstrdup (const char *);
373
374 /* xgetpwnam.c */
375 extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *);
376 /* xgetpwuid.c */
377 extern /*@null@*/ /*@only@*/struct passwd *xgetpwuid (uid_t);
378 /* xgetgrnam.c */
379 extern /*@null@*/ /*@only@*/struct group *xgetgrnam (const char *);
380 /* xgetgrgid.c */
381 extern /*@null@*/ /*@only@*/struct group *xgetgrgid (gid_t);
382 /* xgetspnam.c */
383 extern /*@null@*/ /*@only@*/struct spwd *xgetspnam(const char *);
384
385 /* yesno.c */
386 extern bool yes_or_no (bool read_only);
387
388 #endif                          /* _PROTOTYPES_H */