Mercurial > dropbear
comparison svr-chansession.c @ 1633:592a18dac250
Support servers without multiple user support (#76)
author | Patrick Stewart <patstew@gmail.com> |
---|---|
date | Wed, 20 Mar 2019 14:44:49 +0000 |
parents | 79eef94ccea9 |
children | 8a7d26e86a56 |
comparison
equal
deleted
inserted
replaced
1632:c4bf28ccab97 | 1633:592a18dac250 |
---|---|
947 environ[0] = NULL; | 947 environ[0] = NULL; |
948 } | 948 } |
949 #endif /* HAVE_CLEARENV */ | 949 #endif /* HAVE_CLEARENV */ |
950 #endif /* DEBUG_VALGRIND */ | 950 #endif /* DEBUG_VALGRIND */ |
951 | 951 |
952 #if DROPBEAR_SVR_MULTIUSER | |
952 /* We can only change uid/gid as root ... */ | 953 /* We can only change uid/gid as root ... */ |
953 if (getuid() == 0) { | 954 if (getuid() == 0) { |
954 | 955 |
955 if ((setgid(ses.authstate.pw_gid) < 0) || | 956 if ((setgid(ses.authstate.pw_gid) < 0) || |
956 (initgroups(ses.authstate.pw_name, | 957 (initgroups(ses.authstate.pw_name, |
970 * is for the sysadmin not to give out the UID twice */ | 971 * is for the sysadmin not to give out the UID twice */ |
971 if (getuid() != ses.authstate.pw_uid) { | 972 if (getuid() != ses.authstate.pw_uid) { |
972 dropbear_exit("Couldn't change user as non-root"); | 973 dropbear_exit("Couldn't change user as non-root"); |
973 } | 974 } |
974 } | 975 } |
976 #endif | |
975 | 977 |
976 /* set env vars */ | 978 /* set env vars */ |
977 addnewvar("USER", ses.authstate.pw_name); | 979 addnewvar("USER", ses.authstate.pw_name); |
978 addnewvar("LOGNAME", ses.authstate.pw_name); | 980 addnewvar("LOGNAME", ses.authstate.pw_name); |
979 addnewvar("HOME", ses.authstate.pw_dir); | 981 addnewvar("HOME", ses.authstate.pw_dir); |