OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / tinylogin / tinylogin.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Based in part on code from sash, Copyright (c) 1999 by David I. Bell 
17  * Permission has been granted to redistribute this code under the GPL.
18  *
19  */
20 #ifndef _INTERNAL_H_
21 #define _INTERNAL_H_
22
23 #include CONFIG_H
24 #include <stdlib.h>
25 #include <utmp.h>
26 #include "pwd_grp/pwd.h"
27 #include "pwd_grp/grp.h"
28 #include "shadow_.h"
29 #ifdef TLG_FEATURE_MD5_PASSWORDS
30 # include "md5.h"
31 #endif
32 #ifdef TLG_FEATURE_SHA1_PASSWORDS
33 # include "sha1.h"
34 #endif
35 #include "shadow_.h"
36
37 #include <config/autoconf.h>
38
39 /* Some useful definitions */
40 #define FALSE   ((int) 1)
41 #define TRUE    ((int) 0)
42 #define FAIL_DELAY 3
43 #define TIMEOUT 60
44 #define NOLOGIN_FILE        "/etc/nologin"
45 #ifndef CONFIG_USER_FLATFSD_FLATFSD
46 #define PASSWD_FILE         "/etc/passwd"
47 #define GROUP_FILE          "/etc/group"
48 #else
49 #define PASSWD_FILE         "/etc/config/passwd"
50 #define GROUP_FILE          "/etc/config/group"
51 #endif
52 #define _PATH_LOGIN         "/bin/login"
53 #define CRYPT_EP_SIZE 13                /* Maximum encrypted password size */
54
55
56 enum Location {
57         _TLG_DIR_ROOT = 0,
58         _TLG_DIR_BIN,
59         _TLG_DIR_SBIN,
60         _TLG_DIR_USR_BIN,
61         _TLG_DIR_USR_SBIN
62 };
63
64 struct Applet {
65         const char *name;
66         int (*main) (int argc, char **argv);
67         enum Location location;
68         int need_suid;
69         const char *usage;
70 };
71
72 /* From busybox.c */
73 extern const struct Applet applets[];
74
75 /* Automagically pull in all the applet function prototypes and
76  * applet usage strings.  These are all of the form:
77  *      extern int foo_main(int argc, char **argv);
78  *      extern const char foo_usage[];
79  * These are all autogenerated from the set of currently defined applets. 
80  */
81 #define PROTOTYPES
82 #include "applets.h"
83 #undef PROTOTYPES
84
85 extern const char *applet_name;
86
87
88 /* Utility routines */
89 extern const char *applet_name;
90 extern void usage(const char *usage) __attribute__ ((noreturn));
91 extern void error_msg(const char *s,
92
93                                           ...) __attribute__ ((format(printf, 1, 2)));
94 extern void error_msg_and_die(const char *s,
95                                                           ...) __attribute__ ((noreturn,
96                                                                                                    format(printf, 1, 2)));
97 extern void perror_msg(const char *s,
98                                            ...) __attribute__ ((format(printf, 1, 2)));
99 extern void perror_msg_and_die(const char *s,
100                                                            ...) __attribute__ ((noreturn,
101                                                                                                         format(printf, 1, 2)));
102
103 extern char *pw_encrypt(const char *clear, const char *salt);
104 extern void addenv(const char *string, const char *value);
105 extern void *xmalloc(size_t size);
106 extern char *xstrdup(const char *s);
107 extern void initenv();
108 extern void checkutmp(int picky);
109 extern void updwtmp(const char *filename, const struct utmp *ut);
110 extern void set_env(int argc, char *const *argv);
111 extern void setutmp(const char *name, const char *line);
112 extern void setup_env(struct passwd *info);
113 extern void shell(char *file, char *arg);
114 extern struct spwd *pwd_to_spwd(const struct passwd *pw);
115 extern int update_passwd(const struct passwd *pw, char *crypt_pw);
116 extern int obscure(const char *old, const char *new,
117
118                                    const struct passwd *pwdp);
119
120
121 extern struct utmp utent;
122
123
124 #define STRFCPY(A,B) \
125         (strncpy((A), (B), sizeof(A) - 1), (A)[sizeof(A) - 1] = '\0')
126
127 #include <strings.h>
128
129
130 #ifdef __UC_LIBC__
131 #  define difftime(x, y) ((y) - (x))
132 #endif /* __UC_LIBC__ */
133
134 #endif                                                  /* _INTERNAL_H_ */