version 1.1, 2021/03/09 14:36:01 |
version 1.9, 2021/04/02 12:19:39 |
|
|
/* dgamelaunch.c |
/* dgamelaunch.c |
* |
* |
|
* (c)2021 Rubén Llorente <porting@use.startmail.com> |
* (c)2001-4 M. Drew Streib <dtype@dtype.org> |
* (c)2001-4 M. Drew Streib <dtype@dtype.org> |
* also parts (c) 2003-4 Joshua Kwan <joshk@triplehelix.org>, |
* also parts (c) 2003-4 Joshua Kwan <joshk@triplehelix.org>, |
* Brett Carrington <brettcar@segvio.org>, |
* Brett Carrington <brettcar@segvio.org>, |
|
|
# include <libutil.h> |
# include <libutil.h> |
#elif defined(__NetBSD__) |
#elif defined(__NetBSD__) |
# include <util.h> |
# include <util.h> |
|
#elif defined(__OpenBSD__) |
|
# include <unistd.h> |
#elif defined(__APPLE__) |
#elif defined(__APPLE__) |
# include <unistd.h> |
# include <unistd.h> |
#else |
#else |
Line 1554 changepw (int dowrite) |
|
Line 1557 changepw (int dowrite) |
|
} |
} |
|
|
free(me->password); |
free(me->password); |
|
#if defined(__OpenBSD__) |
|
me->password = (char *) malloc((_PASSWORD_LEN+1)*sizeof(char)); |
|
if ( crypt_newhash(buf, "blowfish,12", me->password, _PASSWORD_LEN) != 0) |
|
graceful_exit(300); |
|
#else |
me->password = strdup (crypt (buf, buf)); |
me->password = strdup (crypt (buf, buf)); |
|
#endif |
|
|
if (dowrite) |
if (dowrite) |
writefile (0); |
writefile (0); |
|
|
int |
int |
passwordgood (char *cpw) |
passwordgood (char *cpw) |
{ |
{ |
|
#if defined(__OpenBSD__) |
|
if ( crypt_checkpass(cpw, me->password) == 0) |
|
return 1; |
|
return 0; |
|
#else |
char *crypted; |
char *crypted; |
assert (me != NULL); |
assert (me != NULL); |
|
|
Line 2063 passwordgood (char *cpw) |
|
Line 2077 passwordgood (char *cpw) |
|
return 1; |
return 1; |
|
|
return 0; |
return 0; |
|
#endif |
} |
} |
|
|
/* ************************************************************* */ |
/* ************************************************************* */ |
Line 2148 readfile (int nolock) |
|
Line 2163 readfile (int nolock) |
|
b = n; |
b = n; |
|
|
/* pw field */ |
/* pw field */ |
|
/* OpenBSD's implementation stores the password in hashed form. |
|
* crypt_checkpass takes care of validating the hashing so we |
|
* don't have to ensure the password field has a valid length */ |
|
|
while (*b != ':') |
while (*b != ':') |
{ |
{ |
users[f_num]->password[(b - n)] = *b; |
users[f_num]->password[(b - n)] = *b; |
b++; |
b++; |
|
#if !defined(__OpenBSD__) |
if ((b - n) >= DGL_PASSWDLEN) { |
if ((b - n) >= DGL_PASSWDLEN) { |
debug_write("passwd field too long"); |
debug_write("passwd field too long"); |
graceful_exit (102); |
graceful_exit (102); |
} |
} |
|
#endif |
} |
} |
|
|
/* advance to next field */ |
/* advance to next field */ |
Line 2850 main (int argc, char** argv) |
|
Line 2871 main (int argc, char** argv) |
|
graceful_exit (3); |
graceful_exit (3); |
} |
} |
|
|
|
|
|
|
/* shed privs. this is done immediately after chroot. */ |
/* shed privs. this is done immediately after chroot. */ |
if (setgroups (1, &globalconfig.shed_gid) == -1) |
if (setgroups (1, &globalconfig.shed_gid) == -1) |
{ |
{ |
Line 2868 main (int argc, char** argv) |
|
Line 2891 main (int argc, char** argv) |
|
perror ("setuid"); |
perror ("setuid"); |
graceful_exit (6); |
graceful_exit (6); |
} |
} |
|
|
|
#if defined(__OpenBSD__) |
|
if ( pledge("stdio rpath wpath cpath fattr flock " |
|
"tty proc exec ps", NULL )==-1 ) |
|
{ |
|
perror("pledge"); |
|
graceful_exit (301); |
|
} |
|
#endif |
|
|
} |
} |
|
|
if (globalconfig.locale) { |
if (globalconfig.locale) { |