diff options
author | Damien Miller <djm@mindrot.org> | 2003-05-19 00:13:38 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2003-05-19 00:13:38 +1000 |
commit | 317412502b900ddecdafdfa171da99271846478b (patch) | |
tree | 2e04f618288cdf0c16a98b675b28b8287a15a0c6 | |
parent | e323df6c4851b04386e747a009474f469fe97137 (diff) |
- (djm) Big KNF on openbsd-compat/
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | openbsd-compat/bsd-arc4random.c | 3 | ||||
-rw-r--r-- | openbsd-compat/bsd-cray.c | 799 | ||||
-rw-r--r-- | openbsd-compat/bsd-cray.h | 27 | ||||
-rw-r--r-- | openbsd-compat/bsd-cygwin_util.c | 93 | ||||
-rw-r--r-- | openbsd-compat/bsd-cygwin_util.h | 8 | ||||
-rw-r--r-- | openbsd-compat/bsd-getpeereid.h | 26 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.c | 33 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.h | 27 | ||||
-rw-r--r-- | openbsd-compat/bsd-nextstep.c | 6 | ||||
-rw-r--r-- | openbsd-compat/bsd-nextstep.h | 23 | ||||
-rw-r--r-- | openbsd-compat/bsd-snprintf.c | 557 | ||||
-rw-r--r-- | openbsd-compat/bsd-snprintf.h | 6 | ||||
-rw-r--r-- | openbsd-compat/bsd-waitpid.c | 11 | ||||
-rw-r--r-- | openbsd-compat/bsd-waitpid.h | 4 | ||||
-rw-r--r-- | openbsd-compat/fake-gai-errnos.h | 11 | ||||
-rw-r--r-- | openbsd-compat/fake-getaddrinfo.c | 83 | ||||
-rw-r--r-- | openbsd-compat/fake-getnameinfo.c | 37 | ||||
-rw-r--r-- | openbsd-compat/fake-getnameinfo.h | 6 | ||||
-rw-r--r-- | openbsd-compat/port-aix.c | 15 | ||||
-rw-r--r-- | openbsd-compat/port-irix.c | 20 | ||||
-rw-r--r-- | openbsd-compat/port-irix.h | 11 | ||||
-rw-r--r-- | openbsd-compat/vis.c | 1 |
23 files changed, 868 insertions, 942 deletions
@@ -17,6 +17,7 @@ | |||
17 | - (djm) Remove IPv4 by default hack now that we can specify AF in config | 17 | - (djm) Remove IPv4 by default hack now that we can specify AF in config |
18 | - (djm) Tidy and trim TODO | 18 | - (djm) Tidy and trim TODO |
19 | - (djm) Sync openbsd-compat/ with OpenBSD CVS head | 19 | - (djm) Sync openbsd-compat/ with OpenBSD CVS head |
20 | - (djm) Big KNF on openbsd-compat/ | ||
20 | 21 | ||
21 | 20030517 | 22 | 20030517 |
22 | - (bal) strcat -> strlcat on openbsd-compat/realpath.c (rev 1.8 OpenBSD) | 23 | - (bal) strcat -> strlcat on openbsd-compat/realpath.c (rev 1.8 OpenBSD) |
@@ -1572,4 +1573,4 @@ | |||
1572 | save auth method before monitor_reset_key_state(); bugzilla bug #284; | 1573 | save auth method before monitor_reset_key_state(); bugzilla bug #284; |
1573 | ok provos@ | 1574 | ok provos@ |
1574 | 1575 | ||
1575 | $Id: ChangeLog,v 1.2738 2003/05/18 12:24:09 djm Exp $ | 1576 | $Id: ChangeLog,v 1.2739 2003/05/18 14:13:38 djm Exp $ |
diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c index dd08130d5..5f890968e 100644 --- a/openbsd-compat/bsd-arc4random.c +++ b/openbsd-compat/bsd-arc4random.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "log.h" | 26 | #include "log.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-arc4random.c,v 1.6 2003/03/17 05:13:53 djm Exp $"); | 28 | RCSID("$Id: bsd-arc4random.c,v 1.7 2003/05/18 14:13:38 djm Exp $"); |
29 | 29 | ||
30 | #ifndef HAVE_ARC4RANDOM | 30 | #ifndef HAVE_ARC4RANDOM |
31 | 31 | ||
@@ -70,6 +70,7 @@ void arc4random_stir(void) | |||
70 | fatal("Couldn't obtain random bytes (error %ld)", | 70 | fatal("Couldn't obtain random bytes (error %ld)", |
71 | ERR_get_error()); | 71 | ERR_get_error()); |
72 | RC4_set_key(&rc4, sizeof(rand_buf), rand_buf); | 72 | RC4_set_key(&rc4, sizeof(rand_buf), rand_buf); |
73 | RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf); | ||
73 | memset(rand_buf, 0, sizeof(rand_buf)); | 74 | memset(rand_buf, 0, sizeof(rand_buf)); |
74 | 75 | ||
75 | rc4_ready = REKEY_BYTES; | 76 | rc4_ready = REKEY_BYTES; |
diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c index b04f31004..bff0fea3a 100644 --- a/openbsd-compat/bsd-cray.c +++ b/openbsd-compat/bsd-cray.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: bsd-cray.c,v 1.10 2003/05/02 21:32:56 dtucker Exp $ | 2 | * $Id: bsd-cray.c,v 1.11 2003/05/18 14:13:38 djm Exp $ |
3 | * | 3 | * |
4 | * bsd-cray.c | 4 | * bsd-cray.c |
5 | * | 5 | * |
@@ -67,10 +67,10 @@ | |||
67 | 67 | ||
68 | extern ServerOptions options; | 68 | extern ServerOptions options; |
69 | 69 | ||
70 | char cray_tmpdir[TPATHSIZ+1]; /* job TMPDIR path */ | 70 | char cray_tmpdir[TPATHSIZ + 1]; /* job TMPDIR path */ |
71 | 71 | ||
72 | struct sysv sysv; /* system security structure */ | 72 | struct sysv sysv; /* system security structure */ |
73 | struct usrv usrv; /* user security structure */ | 73 | struct usrv usrv; /* user security structure */ |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * Functions. | 76 | * Functions. |
@@ -86,39 +86,40 @@ int cray_access_denied(char *); | |||
86 | void | 86 | void |
87 | cray_login_failure(char *username, int errcode) | 87 | cray_login_failure(char *username, int errcode) |
88 | { | 88 | { |
89 | struct udb *ueptr; /* UDB pointer for username */ | 89 | struct udb *ueptr; /* UDB pointer for username */ |
90 | ia_failure_t fsent; /* ia_failure structure */ | 90 | ia_failure_t fsent; /* ia_failure structure */ |
91 | ia_failure_ret_t fret; /* ia_failure return stuff */ | 91 | ia_failure_ret_t fret; /* ia_failure return stuff */ |
92 | struct jtab jtab; /* job table structure */ | 92 | struct jtab jtab; /* job table structure */ |
93 | int jid = 0; /* job id */ | 93 | int jid = 0; /* job id */ |
94 | 94 | ||
95 | if ((jid = getjtab(&jtab)) < 0) { | 95 | if ((jid = getjtab(&jtab)) < 0) |
96 | debug("cray_login_failure(): getjtab error"); | 96 | debug("cray_login_failure(): getjtab error"); |
97 | } | 97 | |
98 | getsysudb(); | 98 | getsysudb(); |
99 | if ((ueptr = getudbnam(username)) == UDB_NULL) { | 99 | if ((ueptr = getudbnam(username)) == UDB_NULL) |
100 | debug("cray_login_failure(): getudbname() returned NULL"); | 100 | debug("cray_login_failure(): getudbname() returned NULL"); |
101 | } | ||
102 | endudb(); | 101 | endudb(); |
103 | fsent.revision = 0; | 102 | |
104 | fsent.uname = username; | 103 | memset(&fsent, '\0', sizeof(fsent)); |
105 | fsent.host = (char *)get_canonical_hostname(options.verify_reverse_mapping); | 104 | fsent.revision = 0; |
106 | fsent.ttyn = "sshd"; | 105 | fsent.uname = username; |
107 | fsent.caller = IA_SSHD; | 106 | fsent.host = (char *)get_canonical_hostname(options.verify_reverse_mapping); |
108 | fsent.flags = IA_INTERACTIVE; | 107 | fsent.ttyn = "sshd"; |
109 | fsent.ueptr = ueptr; | 108 | fsent.caller = IA_SSHD; |
110 | fsent.jid = jid; | 109 | fsent.flags = IA_INTERACTIVE; |
111 | fsent.errcode = errcode; | 110 | fsent.ueptr = ueptr; |
112 | fsent.pwdp = NULL; | 111 | fsent.jid = jid; |
113 | fsent.exitcode = 0; /* dont exit in ia_failure() */ | 112 | fsent.errcode = errcode; |
114 | 113 | fsent.pwdp = NULL; | |
115 | fret.revision = 0; | 114 | fsent.exitcode = 0; /* dont exit in ia_failure() */ |
116 | fret.normal = 0; | 115 | |
116 | fret.revision = 0; | ||
117 | fret.normal = 0; | ||
117 | 118 | ||
118 | /* | 119 | /* |
119 | * Call ia_failure because of an login failure. | 120 | * Call ia_failure because of an login failure. |
120 | */ | 121 | */ |
121 | ia_failure(&fsent,&fret); | 122 | ia_failure(&fsent, &fret); |
122 | } | 123 | } |
123 | 124 | ||
124 | /* | 125 | /* |
@@ -127,19 +128,20 @@ cray_login_failure(char *username, int errcode) | |||
127 | int | 128 | int |
128 | cray_access_denied(char *username) | 129 | cray_access_denied(char *username) |
129 | { | 130 | { |
130 | struct udb *ueptr; /* UDB pointer for username */ | 131 | struct udb *ueptr; /* UDB pointer for username */ |
131 | int errcode; /* IA errorcode */ | 132 | int errcode; /* IA errorcode */ |
132 | 133 | ||
133 | errcode = 0; | 134 | errcode = 0; |
134 | getsysudb(); | 135 | getsysudb(); |
135 | if ((ueptr = getudbnam(username)) == UDB_NULL) { | 136 | if ((ueptr = getudbnam(username)) == UDB_NULL) |
136 | debug("cray_login_failure(): getudbname() returned NULL"); | 137 | debug("cray_login_failure(): getudbname() returned NULL"); |
137 | } | ||
138 | endudb(); | 138 | endudb(); |
139 | if (ueptr && ueptr->ue_disabled) | 139 | |
140 | if (ueptr != NULL && ueptr->ue_disabled) | ||
140 | errcode = IA_DISABLED; | 141 | errcode = IA_DISABLED; |
141 | if (errcode) | 142 | if (errcode) |
142 | cray_login_failure(username, errcode); | 143 | cray_login_failure(username, errcode); |
144 | |||
143 | return (errcode); | 145 | return (errcode); |
144 | } | 146 | } |
145 | 147 | ||
@@ -158,316 +160,284 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
158 | extern struct udb *getudb(); | 160 | extern struct udb *getudb(); |
159 | extern char *setlimits(); | 161 | extern char *setlimits(); |
160 | 162 | ||
161 | int err; /* error return */ | 163 | int err; /* error return */ |
162 | time_t system_time; /* current system clock */ | 164 | time_t system_time; /* current system clock */ |
163 | time_t expiration_time; /* password expiration time */ | 165 | time_t expiration_time; /* password expiration time */ |
164 | int maxattempts; /* maximum no. of failed login attempts */ | 166 | int maxattempts; /* maximum no. of failed login attempts */ |
165 | int SecureSys; /* unicos security flag */ | 167 | int SecureSys; /* unicos security flag */ |
166 | int minslevel = 0; /* system minimum security level */ | 168 | int minslevel = 0; /* system minimum security level */ |
167 | int i, j; | 169 | int i, j; |
168 | int valid_acct = -1; /* flag for reading valid acct */ | 170 | int valid_acct = -1; /* flag for reading valid acct */ |
169 | char acct_name[MAXACID] = { "" }; /* used to read acct name */ | 171 | char acct_name[MAXACID] = { "" }; /* used to read acct name */ |
170 | struct jtab jtab; /* Job table struct */ | 172 | struct jtab jtab; /* Job table struct */ |
171 | struct udb ue; /* udb entry for logging-in user */ | 173 | struct udb ue; /* udb entry for logging-in user */ |
172 | struct udb *up; /* pointer to UDB entry */ | 174 | struct udb *up; /* pointer to UDB entry */ |
173 | struct secstat secinfo; /* file security attributes */ | 175 | struct secstat secinfo; /* file security attributes */ |
174 | struct servprov init_info; /* used for sesscntl() call */ | 176 | struct servprov init_info; /* used for sesscntl() call */ |
175 | int jid; /* job ID */ | 177 | int jid; /* job ID */ |
176 | int pid; /* process ID */ | 178 | int pid; /* process ID */ |
177 | char *sr; /* status return from setlimits() */ | 179 | char *sr; /* status return from setlimits() */ |
178 | char *ttyn = NULL; /* ttyname or command name*/ | 180 | char *ttyn = NULL; /* ttyname or command name*/ |
179 | char hostname[MAXHOSTNAMELEN]; | 181 | char hostname[MAXHOSTNAMELEN]; |
180 | passwd_t pwdacm, | 182 | /* passwd stuff for ia_user */ |
181 | pwddialup, | 183 | passwd_t pwdacm, pwddialup, pwdudb, pwdwal, pwddce; |
182 | pwdudb, | 184 | ia_user_ret_t uret; /* stuff returned from ia_user */ |
183 | pwdwal, | 185 | ia_user_t usent /* ia_user main structure */ |
184 | pwddce; /* passwd stuff for ia_user */ | 186 | int ia_rcode; /* ia_user return code */ |
185 | ia_user_ret_t uret; /* stuff returned from ia_user */ | 187 | ia_failure_t fsent; /* ia_failure structure */ |
186 | ia_user_t usent; /* ia_user main structure */ | ||
187 | int ia_rcode; /* ia_user return code */ | ||
188 | ia_failure_t fsent; /* ia_failure structure */ | ||
189 | ia_failure_ret_t fret; /* ia_failure return stuff */ | 188 | ia_failure_ret_t fret; /* ia_failure return stuff */ |
190 | ia_success_t ssent; /* ia_success structure */ | 189 | ia_success_t ssent; /* ia_success structure */ |
191 | ia_success_ret_t sret; /* ia_success return stuff */ | 190 | ia_success_ret_t sret; /* ia_success return stuff */ |
192 | int ia_mlsrcode; /* ia_mlsuser return code */ | 191 | int ia_mlsrcode; /* ia_mlsuser return code */ |
193 | int secstatrc; /* [f]secstat return code */ | 192 | int secstatrc; /* [f]secstat return code */ |
194 | 193 | ||
195 | if (SecureSys = (int)sysconf(_SC_CRAY_SECURE_SYS)) { | 194 | if (SecureSys = (int)sysconf(_SC_CRAY_SECURE_SYS)) { |
196 | getsysv(&sysv, sizeof(struct sysv)); | 195 | getsysv(&sysv, sizeof(struct sysv)); |
197 | minslevel = sysv.sy_minlvl; | 196 | minslevel = sysv.sy_minlvl; |
198 | if (getusrv(&usrv) < 0) { | 197 | if (getusrv(&usrv) < 0) |
199 | debug("getusrv() failed, errno = %d",errno); | 198 | fatal("getusrv() failed, errno = %d", errno); |
200 | exit(1); | ||
201 | } | ||
202 | } | 199 | } |
203 | hostname[0] = '\0'; | 200 | hostname[0] = '\0'; |
204 | strncpy(hostname, | 201 | strlcpy(hostname, |
205 | (char *)get_canonical_hostname(options.verify_reverse_mapping), | 202 | (char *)get_canonical_hostname(options.verify_reverse_mapping), |
206 | MAXHOSTNAMELEN); | 203 | MAXHOSTNAMELEN); |
207 | /* | 204 | /* |
208 | * Fetch user's UDB entry. | 205 | * Fetch user's UDB entry. |
209 | */ | 206 | */ |
210 | getsysudb(); | 207 | getsysudb(); |
211 | if ((up = getudbnam(username)) == UDB_NULL) { | 208 | if ((up = getudbnam(username)) == UDB_NULL) |
212 | debug("cannot fetch user's UDB entry"); | 209 | fatal("cannot fetch user's UDB entry"); |
213 | exit(1); | 210 | |
214 | } | 211 | /* |
215 | 212 | * Prevent any possible fudging so perform a data | |
216 | /* | 213 | * safety check and compare the supplied uid against |
217 | * Prevent any possible fudging so perform a data | 214 | * the udb's uid. |
218 | * safety check and compare the supplied uid against | 215 | */ |
219 | * the udb's uid. | 216 | if (up->ue_uid != uid) |
220 | */ | 217 | fatal("IA uid missmatch"); |
221 | if (up->ue_uid != uid) { | ||
222 | debug("IA uid missmatch"); | ||
223 | exit(1); | ||
224 | } | ||
225 | endudb(); | 218 | endudb(); |
226 | 219 | ||
227 | if ((jid = getjtab (&jtab)) < 0) { | 220 | if ((jid = getjtab(&jtab)) < 0) { |
228 | debug("getjtab"); | 221 | debug("getjtab"); |
229 | return -1; | 222 | return(-1); |
230 | } | 223 | } |
231 | pid = getpid(); | 224 | pid = getpid(); |
232 | ttyn = ttyname(0); | 225 | ttyn = ttyname(0); |
233 | if (SecureSys) { | 226 | if (SecureSys) { |
234 | if (ttyn) { | 227 | if (ttyn != NULL) |
235 | secstatrc = secstat(ttyn, &secinfo); | 228 | secstatrc = secstat(ttyn, &secinfo); |
236 | } else { | 229 | else |
237 | secstatrc = fsecstat(1, &secinfo); | 230 | secstatrc = fsecstat(1, &secinfo); |
238 | } | 231 | |
239 | if (secstatrc == 0) { | 232 | if (secstatrc == 0) |
240 | debug("[f]secstat() successful"); | 233 | debug("[f]secstat() successful"); |
241 | } else { | 234 | else |
242 | debug("[f]secstat() error, rc = %d", secstatrc); | 235 | fatal("[f]secstat() error, rc = %d", secstatrc); |
243 | exit(1); | ||
244 | } | ||
245 | } | 236 | } |
246 | if ((ttyn == NULL) && ((char *)command != NULL)) | 237 | if ((ttyn == NULL) && ((char *)command != NULL)) |
247 | ttyn = (char *)command; | 238 | ttyn = (char *)command; |
248 | /* | 239 | /* |
249 | * Initialize all structures to call ia_user | 240 | * Initialize all structures to call ia_user |
250 | */ | 241 | */ |
251 | usent.revision = 0; | 242 | usent.revision = 0; |
252 | usent.uname = username; | 243 | usent.uname = username; |
253 | usent.host = hostname; | 244 | usent.host = hostname; |
254 | usent.ttyn = ttyn; | 245 | usent.ttyn = ttyn; |
255 | usent.caller = IA_SSHD; | 246 | usent.caller = IA_SSHD; |
256 | usent.pswdlist = &pwdacm; | 247 | usent.pswdlist = &pwdacm; |
257 | usent.ueptr = &ue; | 248 | usent.ueptr = &ue; |
258 | usent.flags = IA_INTERACTIVE | IA_FFLAG; | 249 | usent.flags = IA_INTERACTIVE | IA_FFLAG; |
259 | pwdacm.atype = IA_SECURID; | 250 | pwdacm.atype = IA_SECURID; |
260 | pwdacm.pwdp = NULL; | 251 | pwdacm.pwdp = NULL; |
261 | pwdacm.next = &pwdudb; | 252 | pwdacm.next = &pwdudb; |
262 | 253 | ||
263 | pwdudb.atype = IA_UDB; | 254 | pwdudb.atype = IA_UDB; |
264 | pwdudb.pwdp = NULL; | 255 | pwdudb.pwdp = NULL; |
265 | pwdudb.next = &pwddce; | 256 | pwdudb.next = &pwddce; |
266 | 257 | ||
267 | pwddce.atype = IA_DCE; | 258 | pwddce.atype = IA_DCE; |
268 | pwddce.pwdp = NULL; | 259 | pwddce.pwdp = NULL; |
269 | pwddce.next = &pwddialup; | 260 | pwddce.next = &pwddialup; |
270 | 261 | ||
271 | pwddialup.atype = IA_DIALUP; | 262 | pwddialup.atype = IA_DIALUP; |
272 | pwddialup.pwdp = NULL; | 263 | pwddialup.pwdp = NULL; |
273 | /* pwddialup.next = &pwdwal; */ | 264 | /* pwddialup.next = &pwdwal; */ |
274 | pwddialup.next = NULL; | 265 | pwddialup.next = NULL; |
275 | 266 | ||
276 | pwdwal.atype = IA_WAL; | 267 | pwdwal.atype = IA_WAL; |
277 | pwdwal.pwdp = NULL; | 268 | pwdwal.pwdp = NULL; |
278 | pwdwal.next = NULL; | 269 | pwdwal.next = NULL; |
279 | 270 | ||
280 | uret.revision = 0; | 271 | uret.revision = 0; |
281 | uret.pswd = NULL; | 272 | uret.pswd = NULL; |
282 | uret.normal = 0; | 273 | uret.normal = 0; |
283 | 274 | ||
284 | ia_rcode = ia_user(&usent, &uret); | 275 | ia_rcode = ia_user(&usent, &uret); |
285 | 276 | switch (ia_rcode) { | |
286 | switch (ia_rcode) { | 277 | /* |
287 | /* | 278 | * These are acceptable return codes from ia_user() |
288 | * These are acceptable return codes from ia_user() | 279 | */ |
289 | */ | 280 | case IA_UDBWEEK: /* Password Expires in 1 week */ |
290 | case IA_UDBWEEK: /* Password Expires in 1 week */ | 281 | expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; |
291 | expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; | 282 | printf ("WARNING - your current password will expire %s\n", |
292 | printf ("WARNING - your current password will expire %s\n", | 283 | ctime((const time_t *)&expiration_time)); |
293 | ctime((const time_t *)&expiration_time)); | 284 | break; |
294 | break; | 285 | case IA_UDBEXPIRED: |
295 | case IA_UDBEXPIRED: | 286 | if (ttyname(0) != NULL) { |
296 | if (ttyname(0) != NULL) { | 287 | /* Force a password change */ |
297 | /* Force a password change */ | 288 | printf("Your password has expired; Choose a new one.\n"); |
298 | printf("Your password has expired; Choose a new one.\n"); | 289 | execl("/bin/passwd", "passwd", username, 0); |
299 | execl("/bin/passwd", "passwd", username, 0); | 290 | exit(9); |
300 | exit(9); | 291 | } |
301 | } | 292 | break; |
302 | 293 | case IA_NORMAL: /* Normal Return Code */ | |
303 | break; | 294 | break; |
304 | case IA_NORMAL: /* Normal Return Code */ | 295 | case IA_BACKDOOR: |
305 | break; | 296 | /* XXX: can we memset it to zero here so save some of this */ |
306 | case IA_BACKDOOR: | 297 | strlcpy(ue.ue_name, "root", sizeof(ue.ue_name)); |
307 | strcpy(ue.ue_name, "root"); | 298 | strlcpy(ue.ue_dir, "/", sizeof(ue.ue_dir)); |
308 | strcpy(ue.ue_passwd, ""); | 299 | strlcpy(ue.ue_shell, "/bin/sh", sizeof(ue.ue_shell)); |
309 | strcpy(ue.ue_dir, "/"); | 300 | |
310 | strcpy(ue.ue_shell, "/bin/sh"); | 301 | ue.ue_passwd[0] = '\0'; |
311 | strcpy(ue.ue_age, ""); | 302 | ue.ue_age[0] = '\0'; |
312 | strcpy(ue.ue_comment, ""); | 303 | ue.ue_comment[0] = '\0'; |
313 | strcpy(ue.ue_loghost, ""); | 304 | ue.ue_loghost[0] = '\0'; |
314 | strcpy(ue.ue_logline, ""); | 305 | ue.ue_logline[0] = '\0'; |
315 | ue.ue_uid=-1; | 306 | |
316 | ue.ue_nice[UDBRC_INTER]=0; | 307 | ue.ue_uid = -1; |
317 | for (i=0;i<MAXVIDS;i++) | 308 | ue.ue_nice[UDBRC_INTER] = 0; |
318 | ue.ue_gids[i]=0; | 309 | |
319 | ue.ue_logfails=0; | 310 | for (i = 0; i < MAXVIDS; i++) |
320 | ue.ue_minlvl=minslevel; | 311 | ue.ue_gids[i] = 0; |
321 | ue.ue_maxlvl=minslevel; | 312 | |
322 | ue.ue_deflvl=minslevel; | 313 | ue.ue_logfails = 0; |
323 | ue.ue_defcomps=0; | 314 | ue.ue_minlvl = ue.ue_maxlvl = ue.ue_deflvl = minslevel; |
324 | ue.ue_comparts=0; | 315 | ue.ue_defcomps = 0; |
325 | ue.ue_permits=0; | 316 | ue.ue_comparts = 0; |
326 | ue.ue_trap=0; | 317 | ue.ue_permits = 0; |
327 | ue.ue_disabled=0; | 318 | ue.ue_trap = 0; |
328 | ue.ue_logtime=0; | 319 | ue.ue_disabled = 0; |
329 | break; | 320 | ue.ue_logtime = 0; |
330 | case IA_CONSOLE: /* Superuser not from Console */ | 321 | break; |
331 | case IA_TRUSTED: /* Trusted user */ | 322 | case IA_CONSOLE: /* Superuser not from Console */ |
332 | if (options.permit_root_login > PERMIT_NO) | 323 | case IA_TRUSTED: /* Trusted user */ |
333 | break; /* Accept root login */ | 324 | if (options.permit_root_login > PERMIT_NO) |
334 | default: | 325 | break; /* Accept root login */ |
335 | /* | 326 | default: |
336 | * These are failed return codes from ia_user() | 327 | /* |
337 | */ | 328 | * These are failed return codes from ia_user() |
338 | switch (ia_rcode) | 329 | */ |
339 | { | 330 | switch (ia_rcode) |
340 | case IA_BADAUTH: | 331 | { |
341 | printf ("Bad authorization, access denied.\n"); | 332 | case IA_BADAUTH: |
342 | break; | 333 | printf("Bad authorization, access denied.\n"); |
343 | case IA_DIALUPERR: | 334 | break; |
344 | break; | 335 | case IA_DISABLED: |
345 | case IA_DISABLED: | 336 | printf("Your login has been disabled. Contact the system "); |
346 | printf ("Your login has been disabled. Contact the system "); | 337 | printf("administrator for assistance.\n"); |
347 | printf ("administrator for assistance.\n"); | 338 | break; |
348 | break; | 339 | case IA_GETSYSV: |
349 | case IA_GETSYSV: | 340 | printf("getsysv() failed - errno = %d\n", errno); |
350 | printf ("getsysv() failed - errno = %d\n", errno); | 341 | break; |
351 | break; | 342 | case IA_MAXLOGS: |
352 | case IA_LOCALHOST: | 343 | printf("Maximum number of failed login attempts exceeded.\n"); |
353 | break; | 344 | printf("Access denied.\n"); |
354 | case IA_MAXLOGS: | 345 | break; |
355 | printf ("Maximum number of failed login attempts exceeded.\n"); | 346 | case IA_UDBPWDNULL: |
356 | printf ("Access denied.\n"); | 347 | if (SecureSys) |
357 | break; | 348 | printf("NULL Password not allowed on MLS systems.\n"); |
358 | case IA_NOPASS: | 349 | break; |
359 | break; | 350 | default: |
360 | case IA_PUBLIC: | 351 | break; |
361 | break; | 352 | } |
362 | case IA_SECURIDERR: | 353 | |
363 | break; | 354 | /* |
364 | case IA_CONSOLE: | 355 | * Authentication failed. |
365 | break; | 356 | */ |
366 | case IA_TRUSTED: | 357 | printf("sshd: Login incorrect, (0%o)\n", |
367 | break; | 358 | ia_rcode-IA_ERRORCODE); |
368 | case IA_UDBERR: | 359 | |
369 | break; | 360 | /* |
370 | case IA_UDBPWDNULL: | 361 | * Initialize structure for ia_failure |
371 | /* | 362 | * which will exit. |
372 | * NULL password not allowed on MLS systems | 363 | */ |
373 | */ | 364 | fsent.revision = 0; |
374 | if (SecureSys) { | 365 | fsent.uname = username; |
375 | printf("NULL Password not allowed on MLS systems.\n"); | 366 | fsent.host = hostname; |
376 | } | 367 | fsent.ttyn = ttyn; |
377 | break; | 368 | fsent.caller = IA_SSHD; |
378 | case IA_UNKNOWN: | 369 | fsent.flags = IA_INTERACTIVE; |
379 | break; | 370 | fsent.ueptr = &ue; |
380 | case IA_UNKNOWNYP: | 371 | fsent.jid = jid; |
381 | break; | 372 | fsent.errcode = ia_rcode; |
382 | case IA_WALERR: | 373 | fsent.pwdp = uret.pswd; |
383 | break; | 374 | fsent.exitcode = 1; |
384 | default: | 375 | |
385 | /* nothing special */ | 376 | fret.revision = 0; |
386 | ; | 377 | fret.normal = 0; |
387 | } /* 2. switch (ia_rcode) */ | 378 | |
388 | /* | 379 | /* |
389 | * Authentication failed. | 380 | * Call ia_failure because of an IA failure. |
390 | */ | 381 | * There is no return because ia_failure exits. |
391 | printf("sshd: Login incorrect, (0%o)\n", | 382 | */ |
392 | ia_rcode-IA_ERRORCODE); | 383 | ia_failure(&fsent, &fret); |
393 | 384 | ||
394 | /* | 385 | exit(1); |
395 | * Initialize structure for ia_failure | 386 | } |
396 | * which will exit. | 387 | |
397 | */ | ||
398 | fsent.revision = 0; | ||
399 | fsent.uname = username; | ||
400 | fsent.host = hostname; | ||
401 | fsent.ttyn = ttyn; | ||
402 | fsent.caller = IA_SSHD; | ||
403 | fsent.flags = IA_INTERACTIVE; | ||
404 | fsent.ueptr = &ue; | ||
405 | fsent.jid = jid; | ||
406 | fsent.errcode = ia_rcode; | ||
407 | fsent.pwdp = uret.pswd; | ||
408 | fsent.exitcode = 1; | ||
409 | |||
410 | fret.revision = 0; | ||
411 | fret.normal = 0; | ||
412 | |||
413 | /* | ||
414 | * Call ia_failure because of an IA failure. | ||
415 | * There is no return because ia_failure exits. | ||
416 | */ | ||
417 | |||
418 | ia_failure(&fsent,&fret); | ||
419 | |||
420 | exit(1); | ||
421 | } /* 1. switch (ia_rcode) */ | ||
422 | ia_mlsrcode = IA_NORMAL; | 388 | ia_mlsrcode = IA_NORMAL; |
423 | if (SecureSys) { | 389 | if (SecureSys) { |
424 | debug("calling ia_mlsuser()"); | 390 | debug("calling ia_mlsuser()"); |
425 | ia_mlsrcode = ia_mlsuser (&ue, &secinfo, &usrv, NULL, 0); | 391 | ia_mlsrcode = ia_mlsuser(&ue, &secinfo, &usrv, NULL, 0); |
426 | } | 392 | } |
427 | if (ia_mlsrcode != IA_NORMAL) { | 393 | if (ia_mlsrcode != IA_NORMAL) { |
428 | printf("sshd: Login incorrect, (0%o)\n", | 394 | printf("sshd: Login incorrect, (0%o)\n", |
429 | ia_mlsrcode-IA_ERRORCODE); | 395 | ia_mlsrcode-IA_ERRORCODE); |
430 | /* | 396 | /* |
431 | * Initialize structure for ia_failure | 397 | * Initialize structure for ia_failure |
432 | * which will exit. | 398 | * which will exit. |
433 | */ | 399 | */ |
434 | fsent.revision = 0; | 400 | fsent.revision = 0; |
435 | fsent.uname = username; | 401 | fsent.uname = username; |
436 | fsent.host = hostname; | 402 | fsent.host = hostname; |
437 | fsent.ttyn = ttyn; | 403 | fsent.ttyn = ttyn; |
438 | fsent.caller = IA_SSHD; | 404 | fsent.caller = IA_SSHD; |
439 | fsent.flags = IA_INTERACTIVE; | 405 | fsent.flags = IA_INTERACTIVE; |
440 | fsent.ueptr = &ue; | 406 | fsent.ueptr = &ue; |
441 | fsent.jid = jid; | 407 | fsent.jid = jid; |
442 | fsent.errcode = ia_mlsrcode; | 408 | fsent.errcode = ia_mlsrcode; |
443 | fsent.pwdp = uret.pswd; | 409 | fsent.pwdp = uret.pswd; |
444 | fsent.exitcode = 1; | 410 | fsent.exitcode = 1; |
445 | fret.revision = 0; | 411 | fret.revision = 0; |
446 | fret.normal = 0; | 412 | fret.normal = 0; |
447 | 413 | ||
448 | /* | 414 | /* |
449 | * Call ia_failure because of an IA failure. | 415 | * Call ia_failure because of an IA failure. |
450 | * There is no return because ia_failure exits. | 416 | * There is no return because ia_failure exits. |
451 | */ | 417 | */ |
452 | ia_failure(&fsent,&fret); | 418 | ia_failure(&fsent,&fret); |
453 | exit(1); | 419 | exit(1); |
454 | } | 420 | } |
455 | 421 | ||
456 | /* Provide login status information */ | 422 | /* Provide login status information */ |
457 | if (options.print_lastlog && ue.ue_logtime != 0) { | 423 | if (options.print_lastlog && ue.ue_logtime != 0) { |
458 | printf("Last successful login was : %.*s ", | 424 | printf("Last successful login was : %.*s ", 19, |
459 | 19, (char *)ctime(&ue.ue_logtime)); | 425 | (char *)ctime(&ue.ue_logtime)); |
460 | 426 | ||
461 | if (*ue.ue_loghost != '\0') | 427 | if (*ue.ue_loghost != '\0') { |
462 | printf("from %.*s\n", sizeof(ue.ue_loghost), ue.ue_loghost); | 428 | printf("from %.*s\n", sizeof(ue.ue_loghost), |
463 | 429 | ue.ue_loghost); | |
464 | else printf("on %.*s\n", sizeof(ue.ue_logline), ue.ue_logline); | 430 | } else { |
465 | 431 | printf("on %.*s\n", sizeof(ue.ue_logline), | |
466 | if ( SecureSys && (ue.ue_logfails != 0)) | 432 | ue.ue_logline); |
467 | printf(" followed by %d failed attempts\n", ue.ue_logfails); | 433 | } |
468 | } | 434 | |
469 | 435 | if (SecureSys && (ue.ue_logfails != 0)) { | |
470 | 436 | printf(" followed by %d failed attempts\n", | |
437 | ue.ue_logfails); | ||
438 | } | ||
439 | } | ||
440 | |||
471 | /* | 441 | /* |
472 | * Call ia_success to process successful I/A. | 442 | * Call ia_success to process successful I/A. |
473 | */ | 443 | */ |
@@ -481,109 +451,116 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
481 | ssent.jid = jid; | 451 | ssent.jid = jid; |
482 | ssent.errcode = ia_rcode; | 452 | ssent.errcode = ia_rcode; |
483 | ssent.us = NULL; | 453 | ssent.us = NULL; |
484 | ssent.time = 1; /* Set ue_logtime */ | 454 | ssent.time = 1; /* Set ue_logtime */ |
485 | 455 | ||
486 | sret.revision = 0; | 456 | sret.revision = 0; |
487 | sret.normal = 0; | 457 | sret.normal = 0; |
488 | 458 | ||
489 | ia_success(&ssent,&sret); | 459 | ia_success(&ssent, &sret); |
490 | 460 | ||
491 | /* | 461 | /* |
492 | * Query for account, iff > 1 valid acid & askacid permbit | 462 | * Query for account, iff > 1 valid acid & askacid permbit |
493 | */ | 463 | */ |
494 | if (((ue.ue_permbits & PERMBITS_ACCTID) || | 464 | if (((ue.ue_permbits & PERMBITS_ACCTID) || |
495 | (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && | 465 | (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && |
496 | ue.ue_permbits & PERMBITS_ASKACID) { | 466 | ue.ue_permbits & PERMBITS_ASKACID) { |
497 | if (ttyname(0) != NULL) { | 467 | if (ttyname(0) != NULL) { |
498 | debug("cray_setup: ttyname true case, %.100s", ttyname); | 468 | debug("cray_setup: ttyname true case, %.100s", ttyname); |
499 | while (valid_acct == -1) { | 469 | while (valid_acct == -1) { |
500 | printf("Account (? for available accounts)" | 470 | printf("Account (? for available accounts)" |
501 | " [%s]: ", acid2nam(ue.ue_acids[0])); | 471 | " [%s]: ", acid2nam(ue.ue_acids[0])); |
502 | gets(acct_name); | 472 | fgets(acct_name, MAXACID, stdin); |
503 | switch (acct_name[0]) { | 473 | switch (acct_name[0]) { |
504 | case EOF: | 474 | case EOF: |
505 | exit(0); | 475 | exit(0); |
506 | break; | 476 | break; |
507 | case '\0': | 477 | case '\0': |
508 | valid_acct = ue.ue_acids[0]; | 478 | valid_acct = ue.ue_acids[0]; |
509 | strcpy(acct_name, acid2nam(valid_acct)); | 479 | strlcpy(acct_name, acid2nam(valid_acct), MAXACID); |
510 | break; | 480 | break; |
511 | case '?': | 481 | case '?': |
512 | /* Print the list 3 wide */ | 482 | /* Print the list 3 wide */ |
513 | for (i = 0, j = 0; i < MAXVIDS; i++) { | 483 | for (i = 0, j = 0; i < MAXVIDS; i++) { |
514 | if (ue.ue_acids[i] == -1) { | 484 | if (ue.ue_acids[i] == -1) { |
515 | printf("\n"); | 485 | printf("\n"); |
516 | break; | 486 | break; |
517 | } | 487 | } |
518 | if (++j == 4) { | 488 | if (++j == 4) { |
519 | j = 1; | 489 | j = 1; |
520 | printf("\n"); | 490 | printf("\n"); |
521 | } | 491 | } |
522 | printf(" %s", | 492 | printf(" %s", |
523 | acid2nam(ue.ue_acids[i])); | 493 | acid2nam(ue.ue_acids[i])); |
524 | } | 494 | } |
525 | if (ue.ue_permbits & PERMBITS_ACCTID) | 495 | if (ue.ue_permbits & PERMBITS_ACCTID) { |
526 | printf("\"acctid\" permbit also allows" | 496 | printf("\"acctid\" permbit also allows" |
527 | " you to select any valid " | 497 | " you to select any valid " |
528 | "account name.\n"); | 498 | "account name.\n"); |
529 | printf("\n"); | 499 | } |
530 | break; | 500 | printf("\n"); |
531 | default: | 501 | break; |
532 | if ((valid_acct = nam2acid(acct_name)) == -1) printf("Account id not found for" | 502 | default: |
533 | " account name \"%s\"\n\n", | 503 | valid_acct = nam2acid(acct_name); |
534 | acct_name); | 504 | if (valid_acct == -1) { |
535 | break; | 505 | printf( |
536 | } | 506 | "Account id not found for" |
537 | /* | 507 | " account name \"%s\"\n\n", |
538 | * If an account was given, search the user's | 508 | acct_name); |
539 | * acids array to verify they can use this account. | 509 | break; |
540 | */ | 510 | } |
541 | if ((valid_acct != -1) && | 511 | /* |
542 | !(ue.ue_permbits & PERMBITS_ACCTID)) { | 512 | * If an account was given, search the user's |
543 | for (i = 0; i < MAXVIDS; i++) { | 513 | * acids array to verify they can use this account. |
544 | if (ue.ue_acids[i] == -1) | 514 | */ |
545 | break; | 515 | if ((valid_acct != -1) && |
546 | if (valid_acct == ue.ue_acids[i]) | 516 | !(ue.ue_permbits & PERMBITS_ACCTID)) { |
547 | break; | 517 | for (i = 0; i < MAXVIDS; i++) { |
548 | } | 518 | if (ue.ue_acids[i] == -1) |
549 | if (i == MAXVIDS || | 519 | break; |
550 | ue.ue_acids[i] == -1) { | 520 | if (valid_acct == ue.ue_acids[i]) |
551 | fprintf(stderr, "Cannot set" | 521 | break; |
552 | " account name to " | 522 | } |
553 | "\"%s\", permission " | 523 | if (i == MAXVIDS || |
554 | "denied\n\n", acct_name); | 524 | ue.ue_acids[i] == -1) { |
555 | valid_acct = -1; | 525 | fprintf(stderr, "Cannot set" |
556 | } | 526 | " account name to " |
557 | } | 527 | "\"%s\", permission " |
558 | } | 528 | "denied\n\n", acct_name); |
529 | valid_acct = -1; | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | } else { | ||
534 | /* | ||
535 | * The client isn't connected to a terminal and can't | ||
536 | * respond to an acid prompt. Use default acid. | ||
537 | */ | ||
538 | debug("cray_setup: ttyname false case, %.100s", | ||
539 | ttyname); | ||
540 | valid_acct = ue.ue_acids[0]; | ||
541 | } | ||
559 | } else { | 542 | } else { |
560 | /* | 543 | /* |
561 | * The client isn't connected to a terminal and can't | 544 | * The user doesn't have the askacid permbit set or |
562 | * respond to an acid prompt. Use default acid. | 545 | * only has one valid account to use. |
563 | */ | 546 | */ |
564 | debug("cray_setup: ttyname false case, %.100s", ttyname); | ||
565 | valid_acct = ue.ue_acids[0]; | 547 | valid_acct = ue.ue_acids[0]; |
566 | } | 548 | } |
567 | } else { | 549 | if (acctid(0, valid_acct) < 0) { |
568 | /* | 550 | printf ("Bad account id: %d\n", valid_acct); |
569 | * The user doesn't have the askacid permbit set or | 551 | exit(1); |
570 | * only has one valid account to use. | 552 | } |
571 | */ | 553 | |
572 | valid_acct = ue.ue_acids[0]; | 554 | /* |
573 | } | 555 | * Now set shares, quotas, limits, including CPU time for the |
574 | if (acctid(0, valid_acct) < 0) { | 556 | * (interactive) job and process, and set up permissions |
575 | printf ("Bad account id: %d\n", valid_acct); | 557 | * (for chown etc), etc. |
576 | exit(1); | 558 | */ |
577 | } | ||
578 | |||
579 | /* set up shares and quotas */ | ||
580 | /* Now set shares, quotas, limits, including CPU time for the (interactive) | ||
581 | * job and process, and set up permissions (for chown etc), etc. | ||
582 | */ | ||
583 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { | 559 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { |
584 | printf("Unable to give %d shares to <%s>(%d/%d)\n", ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); | 560 | printf("Unable to give %d shares to <%s>(%d/%d)\n", |
561 | ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); | ||
585 | exit(1); | 562 | exit(1); |
586 | } | 563 | } |
587 | 564 | ||
588 | sr = setlimits(username, C_PROC, pid, UDBRC_INTER); | 565 | sr = setlimits(username, C_PROC, pid, UDBRC_INTER); |
589 | if (sr != NULL) { | 566 | if (sr != NULL) { |
@@ -596,17 +573,15 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
596 | exit(1); | 573 | exit(1); |
597 | } | 574 | } |
598 | /* | 575 | /* |
599 | * Place the service provider information into | 576 | * Place the service provider information into |
600 | * the session table (Unicos) or job table (Unicos/mk). | 577 | * the session table (Unicos) or job table (Unicos/mk). |
601 | * There exist double defines for the job/session table in | 578 | * There exist double defines for the job/session table in |
602 | * unicos/mk (jtab.h) so no need for a compile time switch. | 579 | * unicos/mk (jtab.h) so no need for a compile time switch. |
603 | */ | 580 | */ |
604 | bzero((char *)&init_info, sizeof(struct servprov)); | 581 | memset(&init_info, '\0', sizeof(init_info)); |
605 | init_info.s_sessinit.si_id = URM_SPT_LOGIN; | 582 | init_info.s_sessinit.si_id = URM_SPT_LOGIN; |
606 | init_info.s_sessinit.si_pid = getpid(); | 583 | init_info.s_sessinit.si_pid = getpid(); |
607 | init_info.s_sessinit.si_sid = jid; | 584 | init_info.s_sessinit.si_sid = jid; |
608 | init_info.s_routing.seqno = 0; | ||
609 | init_info.s_routing.iadrs = 0; | ||
610 | sesscntl(0, S_SETSERVPO, (int)&init_info); | 585 | sesscntl(0, S_SETSERVPO, (int)&init_info); |
611 | 586 | ||
612 | /* | 587 | /* |
@@ -619,7 +594,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
619 | } | 594 | } |
620 | } | 595 | } |
621 | 596 | ||
622 | return(0); | 597 | return (0); |
623 | } | 598 | } |
624 | 599 | ||
625 | /* | 600 | /* |
@@ -632,10 +607,10 @@ void | |||
632 | drop_cray_privs() | 607 | drop_cray_privs() |
633 | { | 608 | { |
634 | #if defined(_SC_CRAY_PRIV_SU) | 609 | #if defined(_SC_CRAY_PRIV_SU) |
635 | priv_proc_t* privstate; | 610 | priv_proc_t *privstate; |
636 | int result; | 611 | int result; |
637 | extern int priv_set_proc(); | 612 | extern int priv_set_proc(); |
638 | extern priv_proc_t* priv_init_proc(); | 613 | extern priv_proc_t *priv_init_proc(); |
639 | 614 | ||
640 | /* | 615 | /* |
641 | * If ether of theses two flags are not set | 616 | * If ether of theses two flags are not set |
@@ -663,15 +638,17 @@ drop_cray_privs() | |||
663 | usrv.sv_intcat = TFM_SYSTEM; | 638 | usrv.sv_intcat = TFM_SYSTEM; |
664 | usrv.sv_valcat |= (TFM_SYSTEM | TFM_SYSFILE); | 639 | usrv.sv_valcat |= (TFM_SYSTEM | TFM_SYSFILE); |
665 | 640 | ||
666 | if (setusrv(&usrv) < 0) | 641 | if (setusrv(&usrv) < 0) { |
667 | fatal("%s(%d): setusrv(): %s", __FILE__, __LINE__, | 642 | fatal("%s(%d): setusrv(): %s", __FILE__, __LINE__, |
668 | strerror(errno)); | 643 | strerror(errno)); |
644 | } | ||
669 | 645 | ||
670 | if ((privstate = priv_init_proc()) != NULL) { | 646 | if ((privstate = priv_init_proc()) != NULL) { |
671 | result = priv_set_proc(privstate); | 647 | result = priv_set_proc(privstate); |
672 | if (result != 0 ) | 648 | if (result != 0 ) { |
673 | fatal("%s(%d): priv_set_proc(): %s", | 649 | fatal("%s(%d): priv_set_proc(): %s", |
674 | __FILE__, __LINE__, strerror(errno)); | 650 | __FILE__, __LINE__, strerror(errno)); |
651 | } | ||
675 | priv_free_proc(privstate); | 652 | priv_free_proc(privstate); |
676 | } | 653 | } |
677 | debug ("Privileges should be cleared..."); | 654 | debug ("Privileges should be cleared..."); |
@@ -692,6 +669,7 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
692 | struct utmp utmp; | 669 | struct utmp utmp; |
693 | 670 | ||
694 | if ((fd = open(UTMP_FILE, O_RDONLY)) != -1) { | 671 | if ((fd = open(UTMP_FILE, O_RDONLY)) != -1) { |
672 | /* XXX use atomicio */ | ||
695 | while (read(fd, (char *)&utmp, sizeof(utmp)) == sizeof(utmp)) { | 673 | while (read(fd, (char *)&utmp, sizeof(utmp)) == sizeof(utmp)) { |
696 | if (pid == utmp.ut_pid) { | 674 | if (pid == utmp.ut_pid) { |
697 | ut->ut_jid = utmp.ut_jid; | 675 | ut->ut_jid = utmp.ut_jid; |
@@ -702,9 +680,8 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
702 | } | 680 | } |
703 | } | 681 | } |
704 | close(fd); | 682 | close(fd); |
705 | } | 683 | } else |
706 | else | 684 | fatal("Unable to open utmp file"); |
707 | fatal("Unable to open utmp file"); | ||
708 | } | 685 | } |
709 | 686 | ||
710 | /* | 687 | /* |
@@ -717,11 +694,9 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
717 | void | 694 | void |
718 | cray_delete_tmpdir(char *login, int jid, uid_t uid) | 695 | cray_delete_tmpdir(char *login, int jid, uid_t uid) |
719 | { | 696 | { |
720 | int child; | ||
721 | static char jtmp[TPATHSIZ]; | 697 | static char jtmp[TPATHSIZ]; |
722 | struct stat statbuf; | 698 | struct stat statbuf; |
723 | int c; | 699 | int child, c, wstat; |
724 | int wstat; | ||
725 | 700 | ||
726 | for (c = 'a'; c <= 'z'; c++) { | 701 | for (c = 'a'; c <= 'z'; c++) { |
727 | snprintf(jtmp, TPATHSIZ, "%s/jtmp.%06d%c", JTMPDIR, jid, c); | 702 | snprintf(jtmp, TPATHSIZ, "%s/jtmp.%06d%c", JTMPDIR, jid, c); |
diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index d2489f4bf..433144f6f 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: bsd-cray.h,v 1.8 2003/05/02 13:42:25 dtucker Exp $ | 2 | * $Id: bsd-cray.h,v 1.9 2003/05/18 14:13:39 djm Exp $ |
3 | * | 3 | * |
4 | * bsd-cray.h | 4 | * bsd-cray.h |
5 | * | 5 | * |
@@ -38,23 +38,26 @@ | |||
38 | #define _BSD_CRAY_H | 38 | #define _BSD_CRAY_H |
39 | 39 | ||
40 | #ifdef _UNICOS | 40 | #ifdef _UNICOS |
41 | void cray_init_job(struct passwd *); /* init cray job */ | 41 | |
42 | void cray_job_termination_handler(int); /* process end of job signal */ | 42 | void cray_init_job(struct passwd *); |
43 | void cray_login_failure(char *username, int errcode); | 43 | void cray_job_termination_handler(int); |
44 | int cray_access_denied(char *username); | 44 | void cray_login_failure(char *, int ); |
45 | int cray_access_denied(char *); | ||
45 | #define CUSTOM_FAILED_LOGIN 1 | 46 | #define CUSTOM_FAILED_LOGIN 1 |
46 | void record_failed_login(const char *user, const char *ttyname); | 47 | void record_failed_login(const char *, const char *); |
47 | extern char cray_tmpdir[]; /* cray tmpdir */ | 48 | extern char cray_tmpdir[]; |
49 | |||
48 | #ifndef IA_SSHD | 50 | #ifndef IA_SSHD |
49 | #define IA_SSHD IA_LOGIN | 51 | # define IA_SSHD IA_LOGIN |
50 | #endif | 52 | #endif |
51 | #ifndef MAXHOSTNAMELEN | 53 | #ifndef MAXHOSTNAMELEN |
52 | #define MAXHOSTNAMELEN 64 | 54 | # define MAXHOSTNAMELEN 64 |
53 | #endif | 55 | #endif |
54 | #ifndef _CRAYT3E | 56 | #ifndef _CRAYT3E |
55 | #include <sys/ttold.h> | 57 | # include <sys/ttold.h> |
56 | #define TIOCGPGRP (tIOC|20) | 58 | # define TIOCGPGRP (tIOC|20) |
57 | #endif | ||
58 | #endif | 59 | #endif |
59 | 60 | ||
61 | #endif /* UNICOS */ | ||
62 | |||
60 | #endif /* _BSD_CRAY_H */ | 63 | #endif /* _BSD_CRAY_H */ |
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 0fa5964bc..012ba4c75 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | #include "includes.h" | 32 | #include "includes.h" |
33 | 33 | ||
34 | RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); | 34 | RCSID("$Id: bsd-cygwin_util.c,v 1.10 2003/05/18 14:13:39 djm Exp $"); |
35 | 35 | ||
36 | #ifdef HAVE_CYGWIN | 36 | #ifdef HAVE_CYGWIN |
37 | 37 | ||
@@ -53,7 +53,8 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); | |||
53 | # undef pipe | 53 | # undef pipe |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | int binary_open(const char *filename, int flags, ...) | 56 | int |
57 | binary_open(const char *filename, int flags, ...) | ||
57 | { | 58 | { |
58 | va_list ap; | 59 | va_list ap; |
59 | mode_t mode; | 60 | mode_t mode; |
@@ -61,55 +62,56 @@ int binary_open(const char *filename, int flags, ...) | |||
61 | va_start(ap, flags); | 62 | va_start(ap, flags); |
62 | mode = va_arg(ap, mode_t); | 63 | mode = va_arg(ap, mode_t); |
63 | va_end(ap); | 64 | va_end(ap); |
64 | return open(filename, flags | O_BINARY, mode); | 65 | return (open(filename, flags | O_BINARY, mode)); |
65 | } | 66 | } |
66 | 67 | ||
67 | int binary_pipe(int fd[2]) | 68 | int |
69 | binary_pipe(int fd[2]) | ||
68 | { | 70 | { |
69 | int ret = pipe(fd); | 71 | int ret = pipe(fd); |
70 | 72 | ||
71 | if (!ret) { | 73 | if (!ret) { |
72 | setmode (fd[0], O_BINARY); | 74 | setmode(fd[0], O_BINARY); |
73 | setmode (fd[1], O_BINARY); | 75 | setmode(fd[1], O_BINARY); |
74 | } | 76 | } |
75 | return ret; | 77 | return (ret); |
76 | } | 78 | } |
77 | 79 | ||
78 | #define HAS_CREATE_TOKEN 1 | 80 | #define HAS_CREATE_TOKEN 1 |
79 | #define HAS_NTSEC_BY_DEFAULT 2 | 81 | #define HAS_NTSEC_BY_DEFAULT 2 |
80 | 82 | ||
81 | static int has_capability(int what) | 83 | static int |
84 | has_capability(int what) | ||
82 | { | 85 | { |
83 | /* has_capability() basically calls uname() and checks if | ||
84 | specific capabilities of Cygwin can be evaluated from that. | ||
85 | This simplifies the calling functions which only have to ask | ||
86 | for a capability using has_capability() instead of having | ||
87 | to figure that out by themselves. */ | ||
88 | static int inited; | 86 | static int inited; |
89 | static int has_create_token; | 87 | static int has_create_token; |
90 | static int has_ntsec_by_default; | 88 | static int has_ntsec_by_default; |
91 | 89 | ||
90 | /* | ||
91 | * has_capability() basically calls uname() and checks if | ||
92 | * specific capabilities of Cygwin can be evaluated from that. | ||
93 | * This simplifies the calling functions which only have to ask | ||
94 | * for a capability using has_capability() instead of having | ||
95 | * to figure that out by themselves. | ||
96 | */ | ||
92 | if (!inited) { | 97 | if (!inited) { |
93 | struct utsname uts; | 98 | struct utsname uts; |
94 | char *c; | 99 | char *c; |
95 | 100 | ||
96 | if (!uname(&uts)) { | 101 | if (!uname(&uts)) { |
97 | int major_high = 0; | 102 | int major_high = 0, major_low = 0, minor = 0; |
98 | int major_low = 0; | 103 | int api_major_version = 0, api_minor_version = 0; |
99 | int minor = 0; | ||
100 | int api_major_version = 0; | ||
101 | int api_minor_version = 0; | ||
102 | char *c; | 104 | char *c; |
103 | 105 | ||
104 | sscanf(uts.release, "%d.%d.%d", &major_high, | 106 | sscanf(uts.release, "%d.%d.%d", &major_high, |
105 | &major_low, &minor); | 107 | &major_low, &minor); |
106 | c = strchr(uts.release, '('); | 108 | if ((c = strchr(uts.release, '(')) != NULL) { |
107 | if (c) | ||
108 | sscanf(c + 1, "%d.%d", &api_major_version, | 109 | sscanf(c + 1, "%d.%d", &api_major_version, |
109 | &api_minor_version); | 110 | &api_minor_version); |
111 | } | ||
110 | if (major_high > 1 || | 112 | if (major_high > 1 || |
111 | (major_high == 1 && (major_low > 3 || | 113 | (major_high == 1 && (major_low > 3 || |
112 | (major_low == 3 && minor >= 2)))) | 114 | (major_low == 3 && minor >= 2)))) |
113 | has_create_token = 1; | 115 | has_create_token = 1; |
114 | if (api_major_version > 0 || api_minor_version >= 56) | 116 | if (api_major_version > 0 || api_minor_version >= 56) |
115 | has_ntsec_by_default = 1; | 117 | has_ntsec_by_default = 1; |
@@ -118,14 +120,15 @@ static int has_capability(int what) | |||
118 | } | 120 | } |
119 | switch (what) { | 121 | switch (what) { |
120 | case HAS_CREATE_TOKEN: | 122 | case HAS_CREATE_TOKEN: |
121 | return has_create_token; | 123 | return (has_create_token); |
122 | case HAS_NTSEC_BY_DEFAULT: | 124 | case HAS_NTSEC_BY_DEFAULT: |
123 | return has_ntsec_by_default; | 125 | return (has_ntsec_by_default); |
124 | } | 126 | } |
125 | return 0; | 127 | return (0); |
126 | } | 128 | } |
127 | 129 | ||
128 | int check_nt_auth(int pwd_authenticated, struct passwd *pw) | 130 | int |
131 | check_nt_auth(int pwd_authenticated, struct passwd *pw) | ||
129 | { | 132 | { |
130 | /* | 133 | /* |
131 | * The only authentication which is able to change the user | 134 | * The only authentication which is able to change the user |
@@ -149,34 +152,33 @@ int check_nt_auth(int pwd_authenticated, struct passwd *pw) | |||
149 | has_create_token = 0; | 152 | has_create_token = 0; |
150 | if (has_capability(HAS_CREATE_TOKEN) && | 153 | if (has_capability(HAS_CREATE_TOKEN) && |
151 | (ntsec_on(cygwin) || | 154 | (ntsec_on(cygwin) || |
152 | (has_capability(HAS_NTSEC_BY_DEFAULT) && | 155 | (has_capability(HAS_NTSEC_BY_DEFAULT) && |
153 | !ntsec_off(cygwin)))) | 156 | !ntsec_off(cygwin)))) |
154 | has_create_token = 1; | 157 | has_create_token = 1; |
155 | } | 158 | } |
156 | if (has_create_token < 1 && | 159 | if (has_create_token < 1 && |
157 | !pwd_authenticated && geteuid() != pw->pw_uid) | 160 | !pwd_authenticated && geteuid() != pw->pw_uid) |
158 | return 0; | 161 | return (0); |
159 | } | 162 | } |
160 | return 1; | 163 | return (1); |
161 | } | 164 | } |
162 | 165 | ||
163 | int check_ntsec(const char *filename) | 166 | int |
167 | check_ntsec(const char *filename) | ||
164 | { | 168 | { |
165 | char *cygwin; | 169 | char *cygwin; |
166 | int allow_ntea = 0; | 170 | int allow_ntea = 0, allow_ntsec = 0; |
167 | int allow_ntsec = 0; | ||
168 | struct statfs fsstat; | 171 | struct statfs fsstat; |
169 | 172 | ||
170 | /* Windows 95/98/ME don't support file system security at all. */ | 173 | /* Windows 95/98/ME don't support file system security at all. */ |
171 | if (!is_winnt) | 174 | if (!is_winnt) |
172 | return 0; | 175 | return (0); |
173 | 176 | ||
174 | /* Evaluate current CYGWIN settings. */ | 177 | /* Evaluate current CYGWIN settings. */ |
175 | cygwin = getenv("CYGWIN"); | 178 | cygwin = getenv("CYGWIN"); |
176 | allow_ntea = ntea_on(cygwin); | 179 | allow_ntea = ntea_on(cygwin); |
177 | allow_ntsec = ntsec_on(cygwin) || | 180 | allow_ntsec = ntsec_on(cygwin) || |
178 | (has_capability(HAS_NTSEC_BY_DEFAULT) && | 181 | (has_capability(HAS_NTSEC_BY_DEFAULT) && !ntsec_off(cygwin)); |
179 | !ntsec_off(cygwin)); | ||
180 | 182 | ||
181 | /* | 183 | /* |
182 | * `ntea' is an emulation of POSIX attributes. It doesn't support | 184 | * `ntea' is an emulation of POSIX attributes. It doesn't support |
@@ -185,14 +187,14 @@ int check_ntsec(const char *filename) | |||
185 | * for security checks. | 187 | * for security checks. |
186 | */ | 188 | */ |
187 | if (allow_ntea) | 189 | if (allow_ntea) |
188 | return 1; | 190 | return (1); |
189 | 191 | ||
190 | /* | 192 | /* |
191 | * Retrieve file system flags. In Cygwin, file system flags are | 193 | * Retrieve file system flags. In Cygwin, file system flags are |
192 | * copied to f_type which has no meaning in Win32 itself. | 194 | * copied to f_type which has no meaning in Win32 itself. |
193 | */ | 195 | */ |
194 | if (statfs(filename, &fsstat)) | 196 | if (statfs(filename, &fsstat)) |
195 | return 1; | 197 | return (1); |
196 | 198 | ||
197 | /* | 199 | /* |
198 | * Only file systems supporting ACLs are able to set permissions. | 200 | * Only file systems supporting ACLs are able to set permissions. |
@@ -200,12 +202,13 @@ int check_ntsec(const char *filename) | |||
200 | * ACLs to support POSIX permissions on files. | 202 | * ACLs to support POSIX permissions on files. |
201 | */ | 203 | */ |
202 | if (fsstat.f_type & FS_PERSISTENT_ACLS) | 204 | if (fsstat.f_type & FS_PERSISTENT_ACLS) |
203 | return allow_ntsec; | 205 | return (allow_ntsec); |
204 | 206 | ||
205 | return 0; | 207 | return (0); |
206 | } | 208 | } |
207 | 209 | ||
208 | void register_9x_service(void) | 210 | void |
211 | register_9x_service(void) | ||
209 | { | 212 | { |
210 | HINSTANCE kerneldll; | 213 | HINSTANCE kerneldll; |
211 | DWORD (*RegisterServiceProcess)(DWORD, DWORD); | 214 | DWORD (*RegisterServiceProcess)(DWORD, DWORD); |
@@ -219,10 +222,10 @@ void register_9x_service(void) | |||
219 | */ | 222 | */ |
220 | if (is_winnt) | 223 | if (is_winnt) |
221 | return; | 224 | return; |
222 | if (! (kerneldll = LoadLibrary("KERNEL32.DLL"))) | 225 | if (!(kerneldll = LoadLibrary("KERNEL32.DLL"))) |
223 | return; | 226 | return; |
224 | if (! (RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) | 227 | if (!(RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) |
225 | GetProcAddress(kerneldll, "RegisterServiceProcess"))) | 228 | GetProcAddress(kerneldll, "RegisterServiceProcess"))) |
226 | return; | 229 | return; |
227 | RegisterServiceProcess(0, 1); | 230 | RegisterServiceProcess(0, 1); |
228 | } | 231 | } |
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h index af470bdd8..859afbef5 100644 --- a/openbsd-compat/bsd-cygwin_util.h +++ b/openbsd-compat/bsd-cygwin_util.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: bsd-cygwin_util.h,v 1.7 2002/04/15 22:00:52 stevesk Exp $ */ | 1 | /* $Id: bsd-cygwin_util.h,v 1.8 2003/05/18 14:13:39 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * cygwin_util.c | 4 | * cygwin_util.c |
@@ -38,10 +38,10 @@ | |||
38 | 38 | ||
39 | #include <io.h> | 39 | #include <io.h> |
40 | 40 | ||
41 | int binary_open(const char *filename, int flags, ...); | 41 | int binary_open(const char *, int , ...); |
42 | int binary_pipe(int fd[2]); | 42 | int binary_pipe(int fd[2]); |
43 | int check_nt_auth(int pwd_authenticated, struct passwd *pw); | 43 | int check_nt_auth(int, struct passwd *); |
44 | int check_ntsec(const char *filename); | 44 | int check_ntsec(const char *); |
45 | void register_9x_service(void); | 45 | void register_9x_service(void); |
46 | 46 | ||
47 | #define open binary_open | 47 | #define open binary_open |
diff --git a/openbsd-compat/bsd-getpeereid.h b/openbsd-compat/bsd-getpeereid.h index 2e9f077f9..771e9cbf9 100644 --- a/openbsd-compat/bsd-getpeereid.h +++ b/openbsd-compat/bsd-getpeereid.h | |||
@@ -1,4 +1,28 @@ | |||
1 | /* $Id: bsd-getpeereid.h,v 1.1 2002/09/12 00:33:02 djm Exp $ */ | 1 | /* |
2 | * Copyright (c) 2002-2003 Damien Miller. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * 1. Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * 2. Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | /* $Id: bsd-getpeereid.h,v 1.2 2003/05/18 14:13:39 djm Exp $ */ | ||
2 | 26 | ||
3 | #ifndef _BSD_GETPEEREID_H | 27 | #ifndef _BSD_GETPEEREID_H |
4 | #define _BSD_GETPEEREID_H | 28 | #define _BSD_GETPEEREID_H |
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index b8e9996d5..cdc63c24d 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 1999-2000 Damien Miller. All rights reserved. | 2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -25,7 +25,7 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "xmalloc.h" | 26 | #include "xmalloc.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $"); | 28 | RCSID("$Id: bsd-misc.c,v 1.13 2003/05/18 14:13:39 djm Exp $"); |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * NB. duplicate __progname in case it is an alias for argv[0] | 31 | * NB. duplicate __progname in case it is an alias for argv[0] |
@@ -41,21 +41,21 @@ char *get_progname(char *argv0) | |||
41 | char *p; | 41 | char *p; |
42 | 42 | ||
43 | if (argv0 == NULL) | 43 | if (argv0 == NULL) |
44 | return "unknown"; /* XXX */ | 44 | return ("unknown"); /* XXX */ |
45 | p = strrchr(argv0, '/'); | 45 | p = strrchr(argv0, '/'); |
46 | if (p == NULL) | 46 | if (p == NULL) |
47 | p = argv0; | 47 | p = argv0; |
48 | else | 48 | else |
49 | p++; | 49 | p++; |
50 | 50 | ||
51 | return xstrdup(p); | 51 | return (xstrdup(p)); |
52 | #endif | 52 | #endif |
53 | } | 53 | } |
54 | 54 | ||
55 | #ifndef HAVE_SETLOGIN | 55 | #ifndef HAVE_SETLOGIN |
56 | int setlogin(const char *name) | 56 | int setlogin(const char *name) |
57 | { | 57 | { |
58 | return(0); | 58 | return (0); |
59 | } | 59 | } |
60 | #endif /* !HAVE_SETLOGIN */ | 60 | #endif /* !HAVE_SETLOGIN */ |
61 | 61 | ||
@@ -63,21 +63,21 @@ int setlogin(const char *name) | |||
63 | int innetgr(const char *netgroup, const char *host, | 63 | int innetgr(const char *netgroup, const char *host, |
64 | const char *user, const char *domain) | 64 | const char *user, const char *domain) |
65 | { | 65 | { |
66 | return(0); | 66 | return (0); |
67 | } | 67 | } |
68 | #endif /* HAVE_INNETGR */ | 68 | #endif /* HAVE_INNETGR */ |
69 | 69 | ||
70 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) | 70 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
71 | int seteuid(uid_t euid) | 71 | int seteuid(uid_t euid) |
72 | { | 72 | { |
73 | return(setreuid(-1,euid)); | 73 | return (setreuid(-1, euid)); |
74 | } | 74 | } |
75 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ | 75 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
76 | 76 | ||
77 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) | 77 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
78 | int setegid(uid_t egid) | 78 | int setegid(uid_t egid) |
79 | { | 79 | { |
80 | return(setresgid(-1,egid,-1)); | 80 | return(setresgid(-1, egid, -1)); |
81 | } | 81 | } |
82 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ | 82 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
83 | 83 | ||
@@ -88,9 +88,9 @@ const char *strerror(int e) | |||
88 | extern char *sys_errlist[]; | 88 | extern char *sys_errlist[]; |
89 | 89 | ||
90 | if ((e >= 0) && (e < sys_nerr)) | 90 | if ((e >= 0) && (e < sys_nerr)) |
91 | return(sys_errlist[e]); | 91 | return (sys_errlist[e]); |
92 | else | 92 | |
93 | return("unlisted error"); | 93 | return ("unlisted error"); |
94 | } | 94 | } |
95 | #endif | 95 | #endif |
96 | 96 | ||
@@ -102,24 +102,25 @@ int utimes(char *filename, struct timeval *tvp) | |||
102 | ub.actime = tvp[0].tv_sec; | 102 | ub.actime = tvp[0].tv_sec; |
103 | ub.modtime = tvp[1].tv_sec; | 103 | ub.modtime = tvp[1].tv_sec; |
104 | 104 | ||
105 | return(utime(filename, &ub)); | 105 | return (utime(filename, &ub)); |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #ifndef HAVE_TRUNCATE | 109 | #ifndef HAVE_TRUNCATE |
110 | int truncate (const char *path, off_t length) | 110 | int truncate(const char *path, off_t length) |
111 | { | 111 | { |
112 | int fd, ret, saverrno; | 112 | int fd, ret, saverrno; |
113 | 113 | ||
114 | fd = open(path, O_WRONLY); | 114 | fd = open(path, O_WRONLY); |
115 | if (fd < 0) | 115 | if (fd < 0) |
116 | return -1; | 116 | return (-1); |
117 | 117 | ||
118 | ret = ftruncate(fd, length); | 118 | ret = ftruncate(fd, length); |
119 | saverrno = errno; | 119 | saverrno = errno; |
120 | (void) close (fd); | 120 | close(fd); |
121 | if (ret == -1) | 121 | if (ret == -1) |
122 | errno = saverrno; | 122 | errno = saverrno; |
123 | |||
123 | return(ret); | 124 | return(ret); |
124 | } | 125 | } |
125 | #endif /* HAVE_TRUNCATE */ | 126 | #endif /* HAVE_TRUNCATE */ |
@@ -131,7 +132,7 @@ int truncate (const char *path, off_t length) | |||
131 | int | 132 | int |
132 | setgroups(size_t size, const gid_t *list) | 133 | setgroups(size_t size, const gid_t *list) |
133 | { | 134 | { |
134 | return 0; | 135 | return (0); |
135 | } | 136 | } |
136 | #endif | 137 | #endif |
137 | 138 | ||
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 78d9ccdd4..00e508cfc 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 1999-2000 Damien Miller. All rights reserved. | 2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -22,42 +22,41 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* $Id: bsd-misc.h,v 1.7 2003/03/18 18:21:41 tim Exp $ */ | 25 | /* $Id: bsd-misc.h,v 1.8 2003/05/18 14:13:39 djm Exp $ */ |
26 | 26 | ||
27 | #ifndef _BSD_MISC_H | 27 | #ifndef _BSD_MISC_H |
28 | #define _BSD_MISC_H | 28 | #define _BSD_MISC_H |
29 | 29 | ||
30 | #include "config.h" | 30 | #include "config.h" |
31 | 31 | ||
32 | char *get_progname(char *argv0); | 32 | char *get_progname(char *); |
33 | 33 | ||
34 | #ifndef HAVE_SETSID | 34 | #ifndef HAVE_SETSID |
35 | #define setsid() setpgrp(0, getpid()) | 35 | #define setsid() setpgrp(0, getpid()) |
36 | #endif /* !HAVE_SETSID */ | 36 | #endif /* !HAVE_SETSID */ |
37 | 37 | ||
38 | #ifndef HAVE_SETENV | 38 | #ifndef HAVE_SETENV |
39 | int setenv(const char *name, const char *value, int overwrite); | 39 | int setenv(const char *, const char *, int); |
40 | #endif /* !HAVE_SETENV */ | 40 | #endif /* !HAVE_SETENV */ |
41 | 41 | ||
42 | #ifndef HAVE_SETLOGIN | 42 | #ifndef HAVE_SETLOGIN |
43 | int setlogin(const char *name); | 43 | int setlogin(const char *); |
44 | #endif /* !HAVE_SETLOGIN */ | 44 | #endif /* !HAVE_SETLOGIN */ |
45 | 45 | ||
46 | #ifndef HAVE_INNETGR | 46 | #ifndef HAVE_INNETGR |
47 | int innetgr(const char *netgroup, const char *host, | 47 | int innetgr(const char *, const char *, const char *, const char *); |
48 | const char *user, const char *domain); | ||
49 | #endif /* HAVE_INNETGR */ | 48 | #endif /* HAVE_INNETGR */ |
50 | 49 | ||
51 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) | 50 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
52 | int seteuid(uid_t euid); | 51 | int seteuid(uid_t); |
53 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ | 52 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
54 | 53 | ||
55 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) | 54 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
56 | int setegid(uid_t egid); | 55 | int setegid(uid_t); |
57 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ | 56 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
58 | 57 | ||
59 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) | 58 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) |
60 | const char *strerror(int e); | 59 | const char *strerror(int); |
61 | #endif | 60 | #endif |
62 | 61 | ||
63 | 62 | ||
@@ -69,15 +68,15 @@ struct timeval { | |||
69 | } | 68 | } |
70 | #endif /* HAVE_STRUCT_TIMEVAL */ | 69 | #endif /* HAVE_STRUCT_TIMEVAL */ |
71 | 70 | ||
72 | int utimes(char *filename, struct timeval *tvp); | 71 | int utimes(char *, struct timeval *); |
73 | #endif /* HAVE_UTIMES */ | 72 | #endif /* HAVE_UTIMES */ |
74 | 73 | ||
75 | #ifndef HAVE_TRUNCATE | 74 | #ifndef HAVE_TRUNCATE |
76 | int truncate (const char *path, off_t length); | 75 | int truncate (const char *, off_t); |
77 | #endif /* HAVE_TRUNCATE */ | 76 | #endif /* HAVE_TRUNCATE */ |
78 | 77 | ||
79 | #if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) | 78 | #if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) |
80 | int setgroups(size_t size, const gid_t *list); | 79 | int setgroups(size_t, const gid_t *); |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) | 82 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) |
@@ -87,7 +86,7 @@ struct timespec { | |||
87 | long tv_nsec; | 86 | long tv_nsec; |
88 | }; | 87 | }; |
89 | #endif | 88 | #endif |
90 | int nanosleep(const struct timespec *req, struct timespec *rem); | 89 | int nanosleep(const struct timespec *, struct timespec *); |
91 | #endif | 90 | #endif |
92 | 91 | ||
93 | #endif /* _BSD_MISC_H */ | 92 | #endif /* _BSD_MISC_H */ |
diff --git a/openbsd-compat/bsd-nextstep.c b/openbsd-compat/bsd-nextstep.c index 85b298a48..5b264ab2f 100644 --- a/openbsd-compat/bsd-nextstep.c +++ b/openbsd-compat/bsd-nextstep.c | |||
@@ -1,3 +1,5 @@ | |||
1 | /* XXX - author */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -22,7 +24,7 @@ | |||
22 | 24 | ||
23 | #include "includes.h" | 25 | #include "includes.h" |
24 | 26 | ||
25 | RCSID("$Id: bsd-nextstep.c,v 1.4 2001/03/26 05:35:34 mouring Exp $"); | 27 | RCSID("$Id: bsd-nextstep.c,v 1.5 2003/05/18 14:13:39 djm Exp $"); |
26 | 28 | ||
27 | #ifdef HAVE_NEXT | 29 | #ifdef HAVE_NEXT |
28 | #include <errno.h> | 30 | #include <errno.h> |
@@ -40,7 +42,7 @@ posix_wait(int *status) | |||
40 | if (status) | 42 | if (status) |
41 | *status = (int) statusp.w_status; | 43 | *status = (int) statusp.w_status; |
42 | 44 | ||
43 | return wait_pid; | 45 | return (wait_pid); |
44 | } | 46 | } |
45 | 47 | ||
46 | int | 48 | int |
diff --git a/openbsd-compat/bsd-nextstep.h b/openbsd-compat/bsd-nextstep.h index c6a7019c6..dc5dc7e17 100644 --- a/openbsd-compat/bsd-nextstep.h +++ b/openbsd-compat/bsd-nextstep.h | |||
@@ -1,3 +1,5 @@ | |||
1 | /* XXX - author */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -21,7 +23,7 @@ | |||
21 | * | 23 | * |
22 | */ | 24 | */ |
23 | 25 | ||
24 | /* $Id: bsd-nextstep.h,v 1.6 2001/03/19 13:42:22 mouring Exp $ */ | 26 | /* $Id: bsd-nextstep.h,v 1.7 2003/05/18 14:13:39 djm Exp $ */ |
25 | 27 | ||
26 | #ifndef _NEXT_POSIX_H | 28 | #ifndef _NEXT_POSIX_H |
27 | #define _NEXT_POSIX_H | 29 | #define _NEXT_POSIX_H |
@@ -37,22 +39,21 @@ | |||
37 | #define dirent direct | 39 | #define dirent direct |
38 | 40 | ||
39 | /* Swap out NeXT's BSD wait() for a more POSIX complient one */ | 41 | /* Swap out NeXT's BSD wait() for a more POSIX complient one */ |
40 | pid_t posix_wait(int *status); | 42 | pid_t posix_wait(int *); |
41 | #define wait(a) posix_wait(a) | 43 | #define wait(a) posix_wait(a) |
42 | 44 | ||
43 | /* #ifdef wrapped functions that need defining for clean compiling */ | 45 | /* #ifdef wrapped functions that need defining for clean compiling */ |
44 | pid_t getppid(void); | 46 | pid_t getppid(void); |
45 | void vhangup(void); | 47 | void vhangup(void); |
46 | int innetgr(const char *netgroup, const char *host, const char *user, | 48 | int innetgr(const char *, const char *, const char *, const char *); |
47 | const char *domain); | ||
48 | 49 | ||
49 | /* TERMCAP */ | 50 | /* TERMCAP */ |
50 | int tcgetattr(int fd, struct termios *t); | 51 | int tcgetattr(int, struct termios *); |
51 | int tcsetattr(int fd, int opt, const struct termios *t); | 52 | int tcsetattr(int, int, const struct termios *); |
52 | int tcsetpgrp(int fd, pid_t pgrp); | 53 | int tcsetpgrp(int, pid_t); |
53 | speed_t cfgetospeed(const struct termios *t); | 54 | speed_t cfgetospeed(const struct termios *); |
54 | speed_t cfgetispeed(const struct termios *t); | 55 | speed_t cfgetispeed(const struct termios *); |
55 | int cfsetospeed(struct termios *t, int speed); | 56 | int cfsetospeed(struct termios *, int); |
56 | int cfsetispeed(struct termios *t, int speed); | 57 | int cfsetispeed(struct termios *, int); |
57 | #endif /* HAVE_NEXT */ | 58 | #endif /* HAVE_NEXT */ |
58 | #endif /* _NEXT_POSIX_H */ | 59 | #endif /* _NEXT_POSIX_H */ |
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c index 2f82180d1..e4d8a439a 100644 --- a/openbsd-compat/bsd-snprintf.c +++ b/openbsd-compat/bsd-snprintf.c | |||
@@ -58,7 +58,7 @@ | |||
58 | 58 | ||
59 | #include "includes.h" | 59 | #include "includes.h" |
60 | 60 | ||
61 | RCSID("$Id: bsd-snprintf.c,v 1.6 2003/04/01 11:31:56 djm Exp $"); | 61 | RCSID("$Id: bsd-snprintf.c,v 1.7 2003/05/18 14:13:39 djm Exp $"); |
62 | 62 | ||
63 | #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ | 63 | #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ |
64 | # undef HAVE_SNPRINTF | 64 | # undef HAVE_SNPRINTF |
@@ -72,15 +72,15 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args); | |||
72 | 72 | ||
73 | static void | 73 | static void |
74 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, | 74 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, |
75 | int min, int max); | 75 | int min, int max); |
76 | 76 | ||
77 | static void | 77 | static void |
78 | fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, | 78 | fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, |
79 | int min, int max, int flags); | 79 | int min, int max, int flags); |
80 | 80 | ||
81 | static void | 81 | static void |
82 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | 82 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, |
83 | int min, int max, int flags); | 83 | int min, int max, int flags); |
84 | 84 | ||
85 | static void | 85 | static void |
86 | dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); | 86 | dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); |
@@ -121,15 +121,10 @@ dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); | |||
121 | static void | 121 | static void |
122 | dopr(char *buffer, size_t maxlen, const char *format, va_list args) | 122 | dopr(char *buffer, size_t maxlen, const char *format, va_list args) |
123 | { | 123 | { |
124 | char *strvalue; | 124 | char *strvalue, ch; |
125 | char ch; | ||
126 | long value; | 125 | long value; |
127 | long double fvalue; | 126 | long double fvalue; |
128 | int min = 0; | 127 | int min = 0, max = -1, state = DP_S_DEFAULT, flags = 0, cflags = 0; |
129 | int max = -1; | ||
130 | int state = DP_S_DEFAULT; | ||
131 | int flags = 0; | ||
132 | int cflags = 0; | ||
133 | size_t currlen = 0; | 128 | size_t currlen = 0; |
134 | 129 | ||
135 | ch = *format++; | 130 | ch = *format++; |
@@ -139,224 +134,224 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) | |||
139 | state = DP_S_DONE; | 134 | state = DP_S_DONE; |
140 | 135 | ||
141 | switch(state) { | 136 | switch(state) { |
142 | case DP_S_DEFAULT: | 137 | case DP_S_DEFAULT: |
143 | if (ch == '%') | 138 | if (ch == '%') |
144 | state = DP_S_FLAGS; | 139 | state = DP_S_FLAGS; |
145 | else | 140 | else |
146 | dopr_outch(buffer, &currlen, maxlen, ch); | 141 | dopr_outch(buffer, &currlen, maxlen, ch); |
142 | ch = *format++; | ||
143 | break; | ||
144 | case DP_S_FLAGS: | ||
145 | switch (ch) { | ||
146 | case '-': | ||
147 | flags |= DP_F_MINUS; | ||
147 | ch = *format++; | 148 | ch = *format++; |
148 | break; | 149 | break; |
149 | case DP_S_FLAGS: | 150 | case '+': |
150 | switch (ch) { | 151 | flags |= DP_F_PLUS; |
151 | case '-': | 152 | ch = *format++; |
152 | flags |= DP_F_MINUS; | ||
153 | ch = *format++; | ||
154 | break; | ||
155 | case '+': | ||
156 | flags |= DP_F_PLUS; | ||
157 | ch = *format++; | ||
158 | break; | ||
159 | case ' ': | ||
160 | flags |= DP_F_SPACE; | ||
161 | ch = *format++; | ||
162 | break; | ||
163 | case '#': | ||
164 | flags |= DP_F_NUM; | ||
165 | ch = *format++; | ||
166 | break; | ||
167 | case '0': | ||
168 | flags |= DP_F_ZERO; | ||
169 | ch = *format++; | ||
170 | break; | ||
171 | default: | ||
172 | state = DP_S_MIN; | ||
173 | break; | ||
174 | } | ||
175 | break; | 153 | break; |
176 | case DP_S_MIN: | 154 | case ' ': |
177 | if (isdigit((unsigned char)ch)) { | 155 | flags |= DP_F_SPACE; |
178 | min = 10*min + char_to_int (ch); | 156 | ch = *format++; |
179 | ch = *format++; | ||
180 | } else if (ch == '*') { | ||
181 | min = va_arg (args, int); | ||
182 | ch = *format++; | ||
183 | state = DP_S_DOT; | ||
184 | } else | ||
185 | state = DP_S_DOT; | ||
186 | break; | 157 | break; |
187 | case DP_S_DOT: | 158 | case '#': |
188 | if (ch == '.') { | 159 | flags |= DP_F_NUM; |
189 | state = DP_S_MAX; | 160 | ch = *format++; |
190 | ch = *format++; | ||
191 | } else | ||
192 | state = DP_S_MOD; | ||
193 | break; | 161 | break; |
194 | case DP_S_MAX: | 162 | case '0': |
195 | if (isdigit((unsigned char)ch)) { | 163 | flags |= DP_F_ZERO; |
196 | if (max < 0) | 164 | ch = *format++; |
197 | max = 0; | ||
198 | max = 10*max + char_to_int(ch); | ||
199 | ch = *format++; | ||
200 | } else if (ch == '*') { | ||
201 | max = va_arg (args, int); | ||
202 | ch = *format++; | ||
203 | state = DP_S_MOD; | ||
204 | } else | ||
205 | state = DP_S_MOD; | ||
206 | break; | 165 | break; |
207 | case DP_S_MOD: | 166 | default: |
208 | switch (ch) { | 167 | state = DP_S_MIN; |
209 | case 'h': | ||
210 | cflags = DP_C_SHORT; | ||
211 | ch = *format++; | ||
212 | break; | ||
213 | case 'l': | ||
214 | cflags = DP_C_LONG; | ||
215 | ch = *format++; | ||
216 | if (ch == 'l') { | ||
217 | cflags = DP_C_LONG_LONG; | ||
218 | ch = *format++; | ||
219 | } | ||
220 | break; | ||
221 | case 'q': | ||
222 | cflags = DP_C_LONG_LONG; | ||
223 | ch = *format++; | ||
224 | break; | ||
225 | case 'L': | ||
226 | cflags = DP_C_LDOUBLE; | ||
227 | ch = *format++; | ||
228 | break; | ||
229 | default: | ||
230 | break; | ||
231 | } | ||
232 | state = DP_S_CONV; | ||
233 | break; | 168 | break; |
234 | case DP_S_CONV: | 169 | } |
235 | switch (ch) { | 170 | break; |
236 | case 'd': | 171 | case DP_S_MIN: |
237 | case 'i': | 172 | if (isdigit((unsigned char)ch)) { |
238 | if (cflags == DP_C_SHORT) | 173 | min = 10 * min + char_to_int (ch); |
239 | value = va_arg(args, int); | 174 | ch = *format++; |
240 | else if (cflags == DP_C_LONG) | 175 | } else if (ch == '*') { |
241 | value = va_arg(args, long int); | 176 | min = va_arg (args, int); |
242 | else if (cflags == DP_C_LONG_LONG) | 177 | ch = *format++; |
243 | value = va_arg (args, long long); | 178 | state = DP_S_DOT; |
244 | else | 179 | } else |
245 | value = va_arg (args, int); | 180 | state = DP_S_DOT; |
246 | fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); | 181 | break; |
247 | break; | 182 | case DP_S_DOT: |
248 | case 'o': | 183 | if (ch == '.') { |
249 | flags |= DP_F_UNSIGNED; | 184 | state = DP_S_MAX; |
250 | if (cflags == DP_C_SHORT) | 185 | ch = *format++; |
251 | value = va_arg(args, unsigned int); | 186 | } else |
252 | else if (cflags == DP_C_LONG) | 187 | state = DP_S_MOD; |
253 | value = va_arg(args, unsigned long int); | 188 | break; |
254 | else if (cflags == DP_C_LONG_LONG) | 189 | case DP_S_MAX: |
255 | value = va_arg(args, unsigned long long); | 190 | if (isdigit((unsigned char)ch)) { |
256 | else | 191 | if (max < 0) |
257 | value = va_arg(args, unsigned int); | 192 | max = 0; |
258 | fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); | 193 | max = 10 * max + char_to_int(ch); |
259 | break; | 194 | ch = *format++; |
260 | case 'u': | 195 | } else if (ch == '*') { |
261 | flags |= DP_F_UNSIGNED; | 196 | max = va_arg (args, int); |
262 | if (cflags == DP_C_SHORT) | 197 | ch = *format++; |
263 | value = va_arg(args, unsigned int); | 198 | state = DP_S_MOD; |
264 | else if (cflags == DP_C_LONG) | 199 | } else |
265 | value = va_arg(args, unsigned long int); | 200 | state = DP_S_MOD; |
266 | else if (cflags == DP_C_LONG_LONG) | 201 | break; |
267 | value = va_arg(args, unsigned long long); | 202 | case DP_S_MOD: |
268 | else | 203 | switch (ch) { |
269 | value = va_arg(args, unsigned int); | 204 | case 'h': |
270 | fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); | 205 | cflags = DP_C_SHORT; |
271 | break; | 206 | ch = *format++; |
272 | case 'X': | 207 | break; |
273 | flags |= DP_F_UP; | 208 | case 'l': |
274 | case 'x': | 209 | cflags = DP_C_LONG; |
275 | flags |= DP_F_UNSIGNED; | 210 | ch = *format++; |
276 | if (cflags == DP_C_SHORT) | 211 | if (ch == 'l') { |
277 | value = va_arg(args, unsigned int); | 212 | cflags = DP_C_LONG_LONG; |
278 | else if (cflags == DP_C_LONG) | 213 | ch = *format++; |
279 | value = va_arg(args, unsigned long int); | ||
280 | else if (cflags == DP_C_LONG_LONG) | ||
281 | value = va_arg(args, unsigned long long); | ||
282 | else | ||
283 | value = va_arg(args, unsigned int); | ||
284 | fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); | ||
285 | break; | ||
286 | case 'f': | ||
287 | if (cflags == DP_C_LDOUBLE) | ||
288 | fvalue = va_arg(args, long double); | ||
289 | else | ||
290 | fvalue = va_arg(args, double); | ||
291 | /* um, floating point? */ | ||
292 | fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); | ||
293 | break; | ||
294 | case 'E': | ||
295 | flags |= DP_F_UP; | ||
296 | case 'e': | ||
297 | if (cflags == DP_C_LDOUBLE) | ||
298 | fvalue = va_arg(args, long double); | ||
299 | else | ||
300 | fvalue = va_arg(args, double); | ||
301 | break; | ||
302 | case 'G': | ||
303 | flags |= DP_F_UP; | ||
304 | case 'g': | ||
305 | if (cflags == DP_C_LDOUBLE) | ||
306 | fvalue = va_arg(args, long double); | ||
307 | else | ||
308 | fvalue = va_arg(args, double); | ||
309 | break; | ||
310 | case 'c': | ||
311 | dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); | ||
312 | break; | ||
313 | case 's': | ||
314 | strvalue = va_arg(args, char *); | ||
315 | if (max < 0) | ||
316 | max = maxlen; /* ie, no max */ | ||
317 | fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); | ||
318 | break; | ||
319 | case 'p': | ||
320 | strvalue = va_arg(args, void *); | ||
321 | fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); | ||
322 | break; | ||
323 | case 'n': | ||
324 | if (cflags == DP_C_SHORT) { | ||
325 | short int *num; | ||
326 | num = va_arg(args, short int *); | ||
327 | *num = currlen; | ||
328 | } else if (cflags == DP_C_LONG) { | ||
329 | long int *num; | ||
330 | num = va_arg(args, long int *); | ||
331 | *num = currlen; | ||
332 | } else if (cflags == DP_C_LONG_LONG) { | ||
333 | long long *num; | ||
334 | num = va_arg(args, long long *); | ||
335 | *num = currlen; | ||
336 | } else { | ||
337 | int *num; | ||
338 | num = va_arg(args, int *); | ||
339 | *num = currlen; | ||
340 | } | ||
341 | break; | ||
342 | case '%': | ||
343 | dopr_outch(buffer, &currlen, maxlen, ch); | ||
344 | break; | ||
345 | case 'w': /* not supported yet, treat as next char */ | ||
346 | ch = *format++; | ||
347 | break; | ||
348 | default: /* Unknown, skip */ | ||
349 | break; | ||
350 | } | 214 | } |
215 | break; | ||
216 | case 'q': | ||
217 | cflags = DP_C_LONG_LONG; | ||
218 | ch = *format++; | ||
219 | break; | ||
220 | case 'L': | ||
221 | cflags = DP_C_LDOUBLE; | ||
351 | ch = *format++; | 222 | ch = *format++; |
352 | state = DP_S_DEFAULT; | ||
353 | flags = cflags = min = 0; | ||
354 | max = -1; | ||
355 | break; | 223 | break; |
356 | case DP_S_DONE: | 224 | default: |
225 | break; | ||
226 | } | ||
227 | state = DP_S_CONV; | ||
228 | break; | ||
229 | case DP_S_CONV: | ||
230 | switch (ch) { | ||
231 | case 'd': | ||
232 | case 'i': | ||
233 | if (cflags == DP_C_SHORT) | ||
234 | value = va_arg(args, int); | ||
235 | else if (cflags == DP_C_LONG) | ||
236 | value = va_arg(args, long int); | ||
237 | else if (cflags == DP_C_LONG_LONG) | ||
238 | value = va_arg (args, long long); | ||
239 | else | ||
240 | value = va_arg (args, int); | ||
241 | fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); | ||
242 | break; | ||
243 | case 'o': | ||
244 | flags |= DP_F_UNSIGNED; | ||
245 | if (cflags == DP_C_SHORT) | ||
246 | value = va_arg(args, unsigned int); | ||
247 | else if (cflags == DP_C_LONG) | ||
248 | value = va_arg(args, unsigned long int); | ||
249 | else if (cflags == DP_C_LONG_LONG) | ||
250 | value = va_arg(args, unsigned long long); | ||
251 | else | ||
252 | value = va_arg(args, unsigned int); | ||
253 | fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); | ||
357 | break; | 254 | break; |
358 | default: /* hmm? */ | 255 | case 'u': |
359 | break; /* some picky compilers need this */ | 256 | flags |= DP_F_UNSIGNED; |
257 | if (cflags == DP_C_SHORT) | ||
258 | value = va_arg(args, unsigned int); | ||
259 | else if (cflags == DP_C_LONG) | ||
260 | value = va_arg(args, unsigned long int); | ||
261 | else if (cflags == DP_C_LONG_LONG) | ||
262 | value = va_arg(args, unsigned long long); | ||
263 | else | ||
264 | value = va_arg(args, unsigned int); | ||
265 | fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); | ||
266 | break; | ||
267 | case 'X': | ||
268 | flags |= DP_F_UP; | ||
269 | case 'x': | ||
270 | flags |= DP_F_UNSIGNED; | ||
271 | if (cflags == DP_C_SHORT) | ||
272 | value = va_arg(args, unsigned int); | ||
273 | else if (cflags == DP_C_LONG) | ||
274 | value = va_arg(args, unsigned long int); | ||
275 | else if (cflags == DP_C_LONG_LONG) | ||
276 | value = va_arg(args, unsigned long long); | ||
277 | else | ||
278 | value = va_arg(args, unsigned int); | ||
279 | fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); | ||
280 | break; | ||
281 | case 'f': | ||
282 | if (cflags == DP_C_LDOUBLE) | ||
283 | fvalue = va_arg(args, long double); | ||
284 | else | ||
285 | fvalue = va_arg(args, double); | ||
286 | /* um, floating point? */ | ||
287 | fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); | ||
288 | break; | ||
289 | case 'E': | ||
290 | flags |= DP_F_UP; | ||
291 | case 'e': | ||
292 | if (cflags == DP_C_LDOUBLE) | ||
293 | fvalue = va_arg(args, long double); | ||
294 | else | ||
295 | fvalue = va_arg(args, double); | ||
296 | break; | ||
297 | case 'G': | ||
298 | flags |= DP_F_UP; | ||
299 | case 'g': | ||
300 | if (cflags == DP_C_LDOUBLE) | ||
301 | fvalue = va_arg(args, long double); | ||
302 | else | ||
303 | fvalue = va_arg(args, double); | ||
304 | break; | ||
305 | case 'c': | ||
306 | dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); | ||
307 | break; | ||
308 | case 's': | ||
309 | strvalue = va_arg(args, char *); | ||
310 | if (max < 0) | ||
311 | max = maxlen; /* ie, no max */ | ||
312 | fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); | ||
313 | break; | ||
314 | case 'p': | ||
315 | strvalue = va_arg(args, void *); | ||
316 | fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); | ||
317 | break; | ||
318 | case 'n': | ||
319 | if (cflags == DP_C_SHORT) { | ||
320 | short int *num; | ||
321 | num = va_arg(args, short int *); | ||
322 | *num = currlen; | ||
323 | } else if (cflags == DP_C_LONG) { | ||
324 | long int *num; | ||
325 | num = va_arg(args, long int *); | ||
326 | *num = currlen; | ||
327 | } else if (cflags == DP_C_LONG_LONG) { | ||
328 | long long *num; | ||
329 | num = va_arg(args, long long *); | ||
330 | *num = currlen; | ||
331 | } else { | ||
332 | int *num; | ||
333 | num = va_arg(args, int *); | ||
334 | *num = currlen; | ||
335 | } | ||
336 | break; | ||
337 | case '%': | ||
338 | dopr_outch(buffer, &currlen, maxlen, ch); | ||
339 | break; | ||
340 | case 'w': /* not supported yet, treat as next char */ | ||
341 | ch = *format++; | ||
342 | break; | ||
343 | default: /* Unknown, skip */ | ||
344 | break; | ||
345 | } | ||
346 | ch = *format++; | ||
347 | state = DP_S_DEFAULT; | ||
348 | flags = cflags = min = 0; | ||
349 | max = -1; | ||
350 | break; | ||
351 | case DP_S_DONE: | ||
352 | break; | ||
353 | default: /* hmm? */ | ||
354 | break; /* some picky compilers need this */ | ||
360 | } | 355 | } |
361 | } | 356 | } |
362 | if (currlen < maxlen - 1) | 357 | if (currlen < maxlen - 1) |
@@ -367,10 +362,9 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) | |||
367 | 362 | ||
368 | static void | 363 | static void |
369 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, | 364 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, |
370 | char *value, int flags, int min, int max) | 365 | char *value, int flags, int min, int max) |
371 | { | 366 | { |
372 | int padlen, strln; /* amount to pad */ | 367 | int cnt = 0, padlen, strln; /* amount to pad */ |
373 | int cnt = 0; | ||
374 | 368 | ||
375 | if (value == 0) | 369 | if (value == 0) |
376 | value = "<NULL>"; | 370 | value = "<NULL>"; |
@@ -402,15 +396,13 @@ fmtstr(char *buffer, size_t *currlen, size_t maxlen, | |||
402 | 396 | ||
403 | static void | 397 | static void |
404 | fmtint(char *buffer, size_t *currlen, size_t maxlen, | 398 | fmtint(char *buffer, size_t *currlen, size_t maxlen, |
405 | long value, int base, int min, int max, int flags) | 399 | long value, int base, int min, int max, int flags) |
406 | { | 400 | { |
407 | unsigned long uvalue; | 401 | unsigned long uvalue; |
408 | char convert[20]; | 402 | char convert[20]; |
409 | int signvalue = 0; | 403 | int signvalue = 0, place = 0, caps = 0; |
410 | int place = 0; | ||
411 | int spadlen = 0; /* amount to space pad */ | 404 | int spadlen = 0; /* amount to space pad */ |
412 | int zpadlen = 0; /* amount to zero pad */ | 405 | int zpadlen = 0; /* amount to zero pad */ |
413 | int caps = 0; | ||
414 | 406 | ||
415 | if (max < 0) | 407 | if (max < 0) |
416 | max = 0; | 408 | max = 0; |
@@ -429,11 +421,10 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, | |||
429 | 421 | ||
430 | if (flags & DP_F_UP) | 422 | if (flags & DP_F_UP) |
431 | caps = 1; /* Should characters be upper case? */ | 423 | caps = 1; /* Should characters be upper case? */ |
432 | |||
433 | do { | 424 | do { |
434 | convert[place++] = | 425 | convert[place++] = |
435 | (caps? "0123456789ABCDEF":"0123456789abcdef") | 426 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
436 | [uvalue % (unsigned)base]; | 427 | [uvalue % (unsigned)base]; |
437 | uvalue = (uvalue / (unsigned)base ); | 428 | uvalue = (uvalue / (unsigned)base ); |
438 | } while (uvalue && (place < 20)); | 429 | } while (uvalue && (place < 20)); |
439 | if (place == 20) | 430 | if (place == 20) |
@@ -453,7 +444,6 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, | |||
453 | if (flags & DP_F_MINUS) | 444 | if (flags & DP_F_MINUS) |
454 | spadlen = -spadlen; /* Left Justifty */ | 445 | spadlen = -spadlen; /* Left Justifty */ |
455 | 446 | ||
456 | |||
457 | /* Spaces */ | 447 | /* Spaces */ |
458 | while (spadlen > 0) { | 448 | while (spadlen > 0) { |
459 | dopr_outch(buffer, currlen, maxlen, ' '); | 449 | dopr_outch(buffer, currlen, maxlen, ' '); |
@@ -512,16 +502,11 @@ static void | |||
512 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | 502 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, |
513 | int min, int max, int flags) | 503 | int min, int max, int flags) |
514 | { | 504 | { |
515 | char iconvert[20]; | 505 | char iconvert[20], fconvert[20]; |
516 | char fconvert[20]; | 506 | int signvalue = 0, iplace = 0, fplace = 0; |
517 | int signvalue = 0; | ||
518 | int iplace = 0; | ||
519 | int fplace = 0; | ||
520 | int padlen = 0; /* amount to pad */ | 507 | int padlen = 0; /* amount to pad */ |
521 | int zpadlen = 0; | 508 | int zpadlen = 0, caps = 0; |
522 | int caps = 0; | 509 | long intpart, fracpart; |
523 | long intpart; | ||
524 | long fracpart; | ||
525 | long double ufvalue; | 510 | long double ufvalue; |
526 | 511 | ||
527 | /* | 512 | /* |
@@ -562,7 +547,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
562 | /* Convert integer part */ | 547 | /* Convert integer part */ |
563 | do { | 548 | do { |
564 | iconvert[iplace++] = | 549 | iconvert[iplace++] = |
565 | (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; | 550 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
551 | [intpart % 10]; | ||
566 | intpart = (intpart / 10); | 552 | intpart = (intpart / 10); |
567 | } while(intpart && (iplace < 20)); | 553 | } while(intpart && (iplace < 20)); |
568 | if (iplace == 20) | 554 | if (iplace == 20) |
@@ -572,7 +558,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
572 | /* Convert fractional part */ | 558 | /* Convert fractional part */ |
573 | do { | 559 | do { |
574 | fconvert[fplace++] = | 560 | fconvert[fplace++] = |
575 | (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; | 561 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
562 | [fracpart % 10]; | ||
576 | fracpart = (fracpart / 10); | 563 | fracpart = (fracpart / 10); |
577 | } while(fracpart && (fplace < 20)); | 564 | } while(fracpart && (fplace < 20)); |
578 | if (fplace == 20) | 565 | if (fplace == 20) |
@@ -611,8 +598,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
611 | dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); | 598 | dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); |
612 | 599 | ||
613 | /* | 600 | /* |
614 | * Decimal point. This should probably use locale to find the correct | 601 | * Decimal point. This should probably use locale to find the |
615 | * char to print out. | 602 | * correct char to print out. |
616 | */ | 603 | */ |
617 | dopr_outch(buffer, currlen, maxlen, '.'); | 604 | dopr_outch(buffer, currlen, maxlen, '.'); |
618 | 605 | ||
@@ -662,90 +649,4 @@ snprintf(char *str,size_t count,const char *fmt,...) | |||
662 | return(strlen(str)); | 649 | return(strlen(str)); |
663 | } | 650 | } |
664 | 651 | ||
665 | #ifdef TEST_SNPRINTF | ||
666 | int | ||
667 | main(void) | ||
668 | { | ||
669 | #define LONG_STRING 1024 | ||
670 | char buf1[LONG_STRING]; | ||
671 | char buf2[LONG_STRING]; | ||
672 | char *fp_fmt[] = { | ||
673 | "%-1.5f", | ||
674 | "%1.5f", | ||
675 | "%123.9f", | ||
676 | "%10.5f", | ||
677 | "% 10.5f", | ||
678 | "%+22.9f", | ||
679 | "%+4.9f", | ||
680 | "%01.3f", | ||
681 | "%4f", | ||
682 | "%3.1f", | ||
683 | "%3.2f", | ||
684 | NULL | ||
685 | }; | ||
686 | double fp_nums[] = { | ||
687 | -1.5, | ||
688 | 134.21, | ||
689 | 91340.2, | ||
690 | 341.1234, | ||
691 | 0203.9, | ||
692 | 0.96, | ||
693 | 0.996, | ||
694 | 0.9996, | ||
695 | 1.996, | ||
696 | 4.136, | ||
697 | 0 | ||
698 | }; | ||
699 | char *int_fmt[] = { | ||
700 | "%-1.5d", | ||
701 | "%1.5d", | ||
702 | "%123.9d", | ||
703 | "%5.5d", | ||
704 | "%10.5d", | ||
705 | "% 10.5d", | ||
706 | "%+22.33d", | ||
707 | "%01.3d", | ||
708 | "%4d", | ||
709 | "%lld", | ||
710 | "%qd", | ||
711 | NULL | ||
712 | }; | ||
713 | long long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 9999999 }; | ||
714 | int x, y; | ||
715 | int fail = 0; | ||
716 | int num = 0; | ||
717 | |||
718 | printf("Testing snprintf format codes against system sprintf...\n"); | ||
719 | |||
720 | for (x = 0; fp_fmt[x] != NULL ; x++) { | ||
721 | for (y = 0; fp_nums[y] != 0 ; y++) { | ||
722 | snprintf(buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); | ||
723 | sprintf (buf2, fp_fmt[x], fp_nums[y]); | ||
724 | if (strcmp (buf1, buf2)) { | ||
725 | printf("snprintf doesn't match Format: %s\n\t" | ||
726 | "snprintf = %s\n\tsprintf = %s\n", | ||
727 | fp_fmt[x], buf1, buf2); | ||
728 | fail++; | ||
729 | } | ||
730 | num++; | ||
731 | } | ||
732 | } | ||
733 | for (x = 0; int_fmt[x] != NULL ; x++) { | ||
734 | for (y = 0; int_nums[y] != 0 ; y++) { | ||
735 | snprintf(buf1, sizeof (buf1), int_fmt[x], int_nums[y]); | ||
736 | sprintf(buf2, int_fmt[x], int_nums[y]); | ||
737 | if (strcmp (buf1, buf2)) { | ||
738 | printf("snprintf doesn't match Format: %s\n\t" | ||
739 | "snprintf = %s\n\tsprintf = %s\n", | ||
740 | int_fmt[x], buf1, buf2); | ||
741 | fail++; | ||
742 | } | ||
743 | num++; | ||
744 | } | ||
745 | } | ||
746 | printf("%d tests failed out of %d.\n", fail, num); | ||
747 | return(0); | ||
748 | } | ||
749 | #endif /* SNPRINTF_TEST */ | ||
750 | |||
751 | #endif /* !HAVE_SNPRINTF */ | 652 | #endif /* !HAVE_SNPRINTF */ |
diff --git a/openbsd-compat/bsd-snprintf.h b/openbsd-compat/bsd-snprintf.h index 002b764e3..95e4d136c 100644 --- a/openbsd-compat/bsd-snprintf.h +++ b/openbsd-compat/bsd-snprintf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: bsd-snprintf.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | 1 | /* $Id: bsd-snprintf.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ |
2 | 2 | ||
3 | #ifndef _BSD_SNPRINTF_H | 3 | #ifndef _BSD_SNPRINTF_H |
4 | #define _BSD_SNPRINTF_H | 4 | #define _BSD_SNPRINTF_H |
@@ -8,11 +8,11 @@ | |||
8 | #include <sys/types.h> /* For size_t */ | 8 | #include <sys/types.h> /* For size_t */ |
9 | 9 | ||
10 | #ifndef HAVE_SNPRINTF | 10 | #ifndef HAVE_SNPRINTF |
11 | int snprintf(char *str, size_t count, const char *fmt, ...); | 11 | int snprintf(char *, size_t, const char *, ...); |
12 | #endif /* !HAVE_SNPRINTF */ | 12 | #endif /* !HAVE_SNPRINTF */ |
13 | 13 | ||
14 | #ifndef HAVE_VSNPRINTF | 14 | #ifndef HAVE_VSNPRINTF |
15 | int vsnprintf(char *str, size_t count, const char *fmt, va_list args); | 15 | int vsnprintf(char *, size_t, const char *, va_list); |
16 | #endif /* !HAVE_SNPRINTF */ | 16 | #endif /* !HAVE_SNPRINTF */ |
17 | 17 | ||
18 | 18 | ||
diff --git a/openbsd-compat/bsd-waitpid.c b/openbsd-compat/bsd-waitpid.c index 47b4446dc..d60081e58 100644 --- a/openbsd-compat/bsd-waitpid.c +++ b/openbsd-compat/bsd-waitpid.c | |||
@@ -1,3 +1,5 @@ | |||
1 | /* XXX - no author */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -22,7 +24,7 @@ | |||
22 | 24 | ||
23 | #include "includes.h" | 25 | #include "includes.h" |
24 | 26 | ||
25 | RCSID("$Id: bsd-waitpid.c,v 1.3 2001/03/26 05:35:34 mouring Exp $"); | 27 | RCSID("$Id: bsd-waitpid.c,v 1.4 2003/05/18 14:13:39 djm Exp $"); |
26 | 28 | ||
27 | #ifndef HAVE_WAITPID | 29 | #ifndef HAVE_WAITPID |
28 | #include <errno.h> | 30 | #include <errno.h> |
@@ -38,15 +40,16 @@ waitpid(int pid, int *stat_loc, int options) | |||
38 | if (pid <= 0) { | 40 | if (pid <= 0) { |
39 | if (pid != -1) { | 41 | if (pid != -1) { |
40 | errno = EINVAL; | 42 | errno = EINVAL; |
41 | return -1; | 43 | return (-1); |
42 | } | 44 | } |
43 | pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */ | 45 | /* wait4() wants pid=0 for indiscriminate wait. */ |
46 | pid = 0; | ||
44 | } | 47 | } |
45 | wait_pid = wait4(pid, &statusp, options, NULL); | 48 | wait_pid = wait4(pid, &statusp, options, NULL); |
46 | if (stat_loc) | 49 | if (stat_loc) |
47 | *stat_loc = (int) statusp.w_status; | 50 | *stat_loc = (int) statusp.w_status; |
48 | 51 | ||
49 | return wait_pid; | 52 | return (wait_pid); |
50 | } | 53 | } |
51 | 54 | ||
52 | #endif /* !HAVE_WAITPID */ | 55 | #endif /* !HAVE_WAITPID */ |
diff --git a/openbsd-compat/bsd-waitpid.h b/openbsd-compat/bsd-waitpid.h index e24edd791..6d48deb29 100644 --- a/openbsd-compat/bsd-waitpid.h +++ b/openbsd-compat/bsd-waitpid.h | |||
@@ -21,7 +21,7 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* $Id: bsd-waitpid.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | 24 | /* $Id: bsd-waitpid.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ |
25 | 25 | ||
26 | #ifndef _BSD_WAITPID_H | 26 | #ifndef _BSD_WAITPID_H |
27 | #define _BSD_WAITPID_H | 27 | #define _BSD_WAITPID_H |
@@ -43,7 +43,7 @@ | |||
43 | #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) | 43 | #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) |
44 | 44 | ||
45 | /* Prototype */ | 45 | /* Prototype */ |
46 | pid_t waitpid(int pid, int *stat_loc, int options); | 46 | pid_t waitpid(int, int *, int); |
47 | 47 | ||
48 | #endif /* !HAVE_WAITPID */ | 48 | #endif /* !HAVE_WAITPID */ |
49 | #endif /* _BSD_WAITPID_H */ | 49 | #endif /* _BSD_WAITPID_H */ |
diff --git a/openbsd-compat/fake-gai-errnos.h b/openbsd-compat/fake-gai-errnos.h index 5edc31b59..8fca7db0c 100644 --- a/openbsd-compat/fake-gai-errnos.h +++ b/openbsd-compat/fake-gai-errnos.h | |||
@@ -5,10 +5,15 @@ | |||
5 | * See getaddrinfo.c and getnameinfo.c. | 5 | * See getaddrinfo.c and getnameinfo.c. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | /* $Id: fake-gai-errnos.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | 8 | #ifndef _FAKE_GAI_ERRNOS_H |
9 | #define _FAKE_GAI_ERRNOS_H | ||
10 | |||
11 | /* $Id: fake-gai-errnos.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ | ||
9 | 12 | ||
10 | /* for old netdb.h */ | 13 | /* for old netdb.h */ |
11 | #ifndef EAI_NODATA | 14 | #ifndef EAI_NODATA |
12 | #define EAI_NODATA 1 | 15 | # define EAI_NODATA 1 |
13 | #define EAI_MEMORY 2 | 16 | # define EAI_MEMORY 2 |
14 | #endif | 17 | #endif |
18 | |||
19 | #endif /* !_FAKE_GAI_ERRNOS_H */ | ||
diff --git a/openbsd-compat/fake-getaddrinfo.c b/openbsd-compat/fake-getaddrinfo.c index 34e1fce78..76b8a6274 100644 --- a/openbsd-compat/fake-getaddrinfo.c +++ b/openbsd-compat/fake-getaddrinfo.c | |||
@@ -10,47 +10,48 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | #include "xmalloc.h" | ||
13 | #include "ssh.h" | 14 | #include "ssh.h" |
14 | 15 | ||
15 | RCSID("$Id: fake-getaddrinfo.c,v 1.6 2003/05/14 11:48:51 dtucker Exp $"); | 16 | RCSID("$Id: fake-getaddrinfo.c,v 1.7 2003/05/18 14:13:39 djm Exp $"); |
16 | 17 | ||
17 | #ifndef HAVE_GAI_STRERROR | 18 | #ifndef HAVE_GAI_STRERROR |
18 | char *gai_strerror(int ecode) | 19 | char * |
20 | gai_strerror(int err) | ||
19 | { | 21 | { |
20 | switch (ecode) { | 22 | switch (err) { |
21 | case EAI_NODATA: | 23 | case EAI_NODATA: |
22 | return "no address associated with hostname."; | 24 | return ("no address associated with name"); |
23 | case EAI_MEMORY: | 25 | case EAI_MEMORY: |
24 | return "memory allocation failure."; | 26 | return ("memory allocation failure."); |
25 | default: | 27 | default: |
26 | return "unknown error."; | 28 | return ("unknown/invalid error."); |
27 | } | 29 | } |
28 | } | 30 | } |
29 | #endif /* !HAVE_GAI_STRERROR */ | 31 | #endif /* !HAVE_GAI_STRERROR */ |
30 | 32 | ||
31 | #ifndef HAVE_FREEADDRINFO | 33 | #ifndef HAVE_FREEADDRINFO |
32 | void freeaddrinfo(struct addrinfo *ai) | 34 | void |
35 | freeaddrinfo(struct addrinfo *ai) | ||
33 | { | 36 | { |
34 | struct addrinfo *next; | 37 | struct addrinfo *next; |
35 | 38 | ||
36 | do { | 39 | for(;ai != NULL; next = ai->ai_next) { |
37 | next = ai->ai_next; | ||
38 | free(ai); | 40 | free(ai); |
39 | } while (NULL != (ai = next)); | 41 | ai = next; |
42 | } | ||
40 | } | 43 | } |
41 | #endif /* !HAVE_FREEADDRINFO */ | 44 | #endif /* !HAVE_FREEADDRINFO */ |
42 | 45 | ||
43 | #ifndef HAVE_GETADDRINFO | 46 | #ifndef HAVE_GETADDRINFO |
44 | static struct addrinfo *malloc_ai(int port, u_long addr, | 47 | static struct |
45 | const struct addrinfo *hints) | 48 | addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) |
46 | { | 49 | { |
47 | struct addrinfo *ai; | 50 | struct addrinfo *ai; |
48 | 51 | ||
49 | ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); | 52 | ai = xmalloc(sizeof(*ai) + sizeof(struct sockaddr_in)); |
50 | if (ai == NULL) | ||
51 | return(NULL); | ||
52 | 53 | ||
53 | memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); | 54 | memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); |
54 | 55 | ||
55 | ai->ai_addr = (struct sockaddr *)(ai + 1); | 56 | ai->ai_addr = (struct sockaddr *)(ai + 1); |
56 | /* XXX -- ssh doesn't use sa_len */ | 57 | /* XXX -- ssh doesn't use sa_len */ |
@@ -69,13 +70,13 @@ static struct addrinfo *malloc_ai(int port, u_long addr, | |||
69 | if (hints->ai_protocol) | 70 | if (hints->ai_protocol) |
70 | ai->ai_protocol = hints->ai_protocol; | 71 | ai->ai_protocol = hints->ai_protocol; |
71 | 72 | ||
72 | return(ai); | 73 | return (ai); |
73 | } | 74 | } |
74 | 75 | ||
75 | int getaddrinfo(const char *hostname, const char *servname, | 76 | int |
76 | const struct addrinfo *hints, struct addrinfo **res) | 77 | getaddrinfo(const char *hostname, const char *servname, |
78 | const struct addrinfo *hints, struct addrinfo **res) | ||
77 | { | 79 | { |
78 | struct addrinfo *cur, *prev = NULL; | ||
79 | struct hostent *hp; | 80 | struct hostent *hp; |
80 | struct servent *sp; | 81 | struct servent *sp; |
81 | struct in_addr in; | 82 | struct in_addr in; |
@@ -100,37 +101,29 @@ int getaddrinfo(const char *hostname, const char *servname, | |||
100 | addr = htonl(0x00000000); | 101 | addr = htonl(0x00000000); |
101 | if (hostname && inet_aton(hostname, &in) != 0) | 102 | if (hostname && inet_aton(hostname, &in) != 0) |
102 | addr = in.s_addr; | 103 | addr = in.s_addr; |
103 | if (NULL != (*res = malloc_ai(port, addr, hints))) | 104 | *res = malloc_ai(port, addr, hints); |
104 | return 0; | 105 | return (0); |
105 | else | ||
106 | return EAI_MEMORY; | ||
107 | } | 106 | } |
108 | 107 | ||
109 | if (!hostname) { | 108 | if (!hostname) { |
110 | if (NULL != (*res = malloc_ai(port, htonl(0x7f000001), hints))) | 109 | *res = malloc_ai(port, htonl(0x7f000001), hints); |
111 | return 0; | 110 | return (0); |
112 | else | ||
113 | return EAI_MEMORY; | ||
114 | } | 111 | } |
115 | 112 | ||
116 | if (inet_aton(hostname, &in)) { | 113 | if (inet_aton(hostname, &in)) { |
117 | if (NULL != (*res = malloc_ai(port, in.s_addr, hints))) | 114 | *res = malloc_ai(port, in.s_addr, hints); |
118 | return 0; | 115 | return (0); |
119 | else | ||
120 | return EAI_MEMORY; | ||
121 | } | 116 | } |
122 | 117 | ||
123 | hp = gethostbyname(hostname); | 118 | hp = gethostbyname(hostname); |
124 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { | 119 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { |
120 | struct addrinfo *cur, *prev; | ||
121 | |||
122 | cur = prev = NULL; | ||
125 | for (i = 0; hp->h_addr_list[i]; i++) { | 123 | for (i = 0; hp->h_addr_list[i]; i++) { |
126 | cur = malloc_ai(port, | 124 | struct in_addr *in = (struct in_addr *)hp->h_addr_list[i]; |
127 | ((struct in_addr *)hp->h_addr_list[i])->s_addr, hints); | 125 | |
128 | if (cur == NULL) { | 126 | cur = malloc_ai(port, in->s_addr, hints); |
129 | if (*res) | ||
130 | freeaddrinfo(*res); | ||
131 | return EAI_MEMORY; | ||
132 | } | ||
133 | |||
134 | if (prev) | 127 | if (prev) |
135 | prev->ai_next = cur; | 128 | prev->ai_next = cur; |
136 | else | 129 | else |
@@ -138,9 +131,9 @@ int getaddrinfo(const char *hostname, const char *servname, | |||
138 | 131 | ||
139 | prev = cur; | 132 | prev = cur; |
140 | } | 133 | } |
141 | return 0; | 134 | return (0); |
142 | } | 135 | } |
143 | 136 | ||
144 | return EAI_NODATA; | 137 | return (EAI_NODATA); |
145 | } | 138 | } |
146 | #endif /* !HAVE_GETADDRINFO */ | 139 | #endif /* !HAVE_GETADDRINFO */ |
diff --git a/openbsd-compat/fake-getnameinfo.c b/openbsd-compat/fake-getnameinfo.c index e255ed333..f3b0913de 100644 --- a/openbsd-compat/fake-getnameinfo.c +++ b/openbsd-compat/fake-getnameinfo.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | #include "ssh.h" | 13 | #include "ssh.h" |
14 | 14 | ||
15 | RCSID("$Id: fake-getnameinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $"); | 15 | RCSID("$Id: fake-getnameinfo.c,v 1.3 2003/05/18 14:13:39 djm Exp $"); |
16 | 16 | ||
17 | #ifndef HAVE_GETNAMEINFO | 17 | #ifndef HAVE_GETNAMEINFO |
18 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | 18 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, |
@@ -22,34 +22,31 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | |||
22 | struct hostent *hp; | 22 | struct hostent *hp; |
23 | char tmpserv[16]; | 23 | char tmpserv[16]; |
24 | 24 | ||
25 | if (serv) { | 25 | if (serv != NULL) { |
26 | snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); | 26 | snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); |
27 | if (strlen(tmpserv) >= servlen) | 27 | if (strlcpy(serv, tmpserv, servlen) >= servlen) |
28 | return EAI_MEMORY; | 28 | return (EAI_MEMORY); |
29 | else | ||
30 | strcpy(serv, tmpserv); | ||
31 | } | 29 | } |
32 | 30 | ||
33 | if (host) { | 31 | if (host != NULL) { |
34 | if (flags & NI_NUMERICHOST) { | 32 | if (flags & NI_NUMERICHOST) { |
35 | if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen) | 33 | if (strlcpy(host, inet_ntoa(sin->sin_addr), |
36 | return EAI_MEMORY; | 34 | hostlen) >= hostlen) |
37 | 35 | return (EAI_MEMORY); | |
38 | strcpy(host, inet_ntoa(sin->sin_addr)); | 36 | else |
39 | return 0; | 37 | return (0); |
40 | } else { | 38 | } else { |
41 | hp = gethostbyaddr((char *)&sin->sin_addr, | 39 | hp = gethostbyaddr((char *)&sin->sin_addr, |
42 | sizeof(struct in_addr), AF_INET); | 40 | sizeof(struct in_addr), AF_INET); |
43 | if (hp == NULL) | 41 | if (hp == NULL) |
44 | return EAI_NODATA; | 42 | return (EAI_NODATA); |
45 | 43 | ||
46 | if (strlen(hp->h_name) >= hostlen) | 44 | if (strlcpy(host, hp->h_name, hostlen) >= hostlen) |
47 | return EAI_MEMORY; | 45 | return (EAI_MEMORY); |
48 | 46 | else | |
49 | strcpy(host, hp->h_name); | 47 | return (0); |
50 | return 0; | ||
51 | } | 48 | } |
52 | } | 49 | } |
53 | return 0; | 50 | return (0); |
54 | } | 51 | } |
55 | #endif /* !HAVE_GETNAMEINFO */ | 52 | #endif /* !HAVE_GETNAMEINFO */ |
diff --git a/openbsd-compat/fake-getnameinfo.h b/openbsd-compat/fake-getnameinfo.h index c9b7908aa..7aaabc7f6 100644 --- a/openbsd-compat/fake-getnameinfo.h +++ b/openbsd-compat/fake-getnameinfo.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: fake-getnameinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | 1 | /* $Id: fake-getnameinfo.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ |
2 | 2 | ||
3 | #ifndef _FAKE_GETNAMEINFO_H | 3 | #ifndef _FAKE_GETNAMEINFO_H |
4 | #define _FAKE_GETNAMEINFO_H | 4 | #define _FAKE_GETNAMEINFO_H |
@@ -6,8 +6,8 @@ | |||
6 | #include "config.h" | 6 | #include "config.h" |
7 | 7 | ||
8 | #ifndef HAVE_GETNAMEINFO | 8 | #ifndef HAVE_GETNAMEINFO |
9 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | 9 | int getnameinfo(const struct sockaddr *, size_t, char *, size_t, |
10 | size_t hostlen, char *serv, size_t servlen, int flags); | 10 | char *, size_t, int); |
11 | #endif /* !HAVE_GETNAMEINFO */ | 11 | #endif /* !HAVE_GETNAMEINFO */ |
12 | 12 | ||
13 | #ifndef NI_MAXSERV | 13 | #ifndef NI_MAXSERV |
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index cddc0907f..7a42810e9 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c | |||
@@ -46,14 +46,18 @@ void | |||
46 | aix_usrinfo(struct passwd *pw) | 46 | aix_usrinfo(struct passwd *pw) |
47 | { | 47 | { |
48 | u_int i; | 48 | u_int i; |
49 | size_t len; | ||
49 | char *cp; | 50 | char *cp; |
50 | 51 | ||
51 | cp = xmalloc(16 + 2 * strlen(pw->pw_name)); | 52 | len = sizeof("LOGNAME= NAME= ") + (2 * strlen(pw->pw_name)); |
52 | i = sprintf(cp, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, 0, | 53 | cp = xmalloc(len); |
53 | pw->pw_name, 0); | 54 | |
55 | i = snprintf(cp, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, '\0', | ||
56 | pw->pw_name, '\0', len); | ||
54 | if (usrinfo(SETUINFO, cp, i) == -1) | 57 | if (usrinfo(SETUINFO, cp, i) == -1) |
55 | fatal("Couldn't set usrinfo: %s", strerror(errno)); | 58 | fatal("Couldn't set usrinfo: %s", strerror(errno)); |
56 | debug3("AIX/UsrInfo: set len %d", i); | 59 | debug3("AIX/UsrInfo: set len %d", i); |
60 | |||
57 | xfree(cp); | 61 | xfree(cp); |
58 | } | 62 | } |
59 | 63 | ||
@@ -64,8 +68,9 @@ aix_usrinfo(struct passwd *pw) | |||
64 | void | 68 | void |
65 | record_failed_login(const char *user, const char *ttyname) | 69 | record_failed_login(const char *user, const char *ttyname) |
66 | { | 70 | { |
67 | loginfailed(user, | 71 | char *hostname = get_canonical_hostname(options.verify_reverse_mapping); |
68 | get_canonical_hostname(options.verify_reverse_mapping), ttyname); | 72 | |
73 | loginfailed(user, hostname, ttyname); | ||
69 | } | 74 | } |
70 | # endif /* CUSTOM_FAILED_LOGIN */ | 75 | # endif /* CUSTOM_FAILED_LOGIN */ |
71 | #endif /* _AIX */ | 76 | #endif /* _AIX */ |
diff --git a/openbsd-compat/port-irix.c b/openbsd-compat/port-irix.c index a63ec429a..1b212980d 100644 --- a/openbsd-compat/port-irix.c +++ b/openbsd-compat/port-irix.c | |||
@@ -1,15 +1,19 @@ | |||
1 | /* XXX - BSD license here */ | ||
2 | |||
1 | #include "includes.h" | 3 | #include "includes.h" |
2 | 4 | ||
3 | #if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) | 5 | #if defined(WITH_IRIX_PROJECT) || \ |
6 | defined(WITH_IRIX_JOBS) || \ | ||
7 | defined(WITH_IRIX_ARRAY) | ||
4 | 8 | ||
5 | #ifdef WITH_IRIX_PROJECT | 9 | #ifdef WITH_IRIX_PROJECT |
6 | #include <proj.h> | 10 | # include <proj.h> |
7 | #endif /* WITH_IRIX_PROJECT */ | 11 | #endif /* WITH_IRIX_PROJECT */ |
8 | #ifdef WITH_IRIX_JOBS | 12 | #ifdef WITH_IRIX_JOBS |
9 | #include <sys/resource.h> | 13 | # include <sys/resource.h> |
10 | #endif | 14 | #endif |
11 | #ifdef WITH_IRIX_AUDIT | 15 | #ifdef WITH_IRIX_AUDIT |
12 | #include <sat.h> | 16 | # include <sat.h> |
13 | #endif /* WITH_IRIX_AUDIT */ | 17 | #endif /* WITH_IRIX_AUDIT */ |
14 | 18 | ||
15 | void | 19 | void |
@@ -17,14 +21,12 @@ irix_setusercontext(struct passwd *pw) | |||
17 | { | 21 | { |
18 | #ifdef WITH_IRIX_PROJECT | 22 | #ifdef WITH_IRIX_PROJECT |
19 | prid_t projid; | 23 | prid_t projid; |
20 | #endif /* WITH_IRIX_PROJECT */ | 24 | #endif |
21 | #ifdef WITH_IRIX_JOBS | 25 | #ifdef WITH_IRIX_JOBS |
22 | jid_t jid = 0; | 26 | jid_t jid = 0; |
23 | #else | 27 | #elif defined(WITH_IRIX_ARRAY) |
24 | # ifdef WITH_IRIX_ARRAY | ||
25 | int jid = 0; | 28 | int jid = 0; |
26 | # endif /* WITH_IRIX_ARRAY */ | 29 | #endif |
27 | #endif /* WITH_IRIX_JOBS */ | ||
28 | 30 | ||
29 | #ifdef WITH_IRIX_JOBS | 31 | #ifdef WITH_IRIX_JOBS |
30 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); | 32 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); |
diff --git a/openbsd-compat/port-irix.h b/openbsd-compat/port-irix.h index 2dd3c2e25..fd9f09e6c 100644 --- a/openbsd-compat/port-irix.h +++ b/openbsd-compat/port-irix.h | |||
@@ -1,5 +1,14 @@ | |||
1 | #if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) | 1 | /* XXX - BSD license */ |
2 | |||
3 | #ifndef _PORT_IRIX_H | ||
4 | #define _PORT_IRIX_H | ||
5 | |||
6 | #if defined(WITH_IRIX_PROJECT) || \ | ||
7 | defined(WITH_IRIX_JOBS) || \ | ||
8 | defined(WITH_IRIX_ARRAY) | ||
2 | 9 | ||
3 | void irix_setusercontext(struct passwd *pw); | 10 | void irix_setusercontext(struct passwd *pw); |
4 | 11 | ||
5 | #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ | 12 | #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ |
13 | |||
14 | #endif /* ! _PORT_IRIX_H */ | ||
diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index 0d15886f0..92b2ac498 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c | |||
@@ -38,6 +38,7 @@ static char rcsid[] = "$OpenBSD: vis.c,v 1.11 2003/05/14 05:16:43 pjanzen Exp $" | |||
38 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
39 | 39 | ||
40 | #include <ctype.h> | 40 | #include <ctype.h> |
41 | #include <string.h> | ||
41 | 42 | ||
42 | #include "vis.h" | 43 | #include "vis.h" |
43 | 44 | ||