setsid();
if (vpninfo->uid_csd_given && vpninfo->uid_csd != getuid()) {
- struct passwd *pw;
+ struct passwd pwd, *result;
+ char buffer[2049]; /* should be sysconf(_SC_GETPW_R_SIZE_MAX) */
int err;
if (setgid(vpninfo->gid_csd)) {
return -err;
}
- if (!(pw = getpwuid(vpninfo->uid_csd))) {
- err = errno;
+ if ((err = getpwuid_r(vpninfo->uid_csd, &pwd, buffer, sizeof(buffer),
+ &result)) || !result) {
fprintf(stderr, _("Invalid user uid=%ld: %s\n"),
(long)vpninfo->uid_csd, strerror(err));
return -err;
}
- setenv("HOME", pw->pw_dir, 1);
- if (chdir(pw->pw_dir)) {
+ setenv("HOME", result->pw_dir, 1);
+ if (chdir(result->pw_dir)) {
err = errno;
fprintf(stderr, _("Failed to change to CSD home directory '%s': %s\n"),
- pw->pw_dir, strerror(err));
+ result->pw_dir, strerror(err));
return -err;
}
}
dtls_state);
if (vpninfo->auth_expiration != 0) {
char buf[80];
- struct tm *tm = localtime(&&vpninfo->auth_expiration);
+ struct tm *tm = localtime(&vpninfo->auth_expiration);
strftime(buf, 80, "%a, %d %b %Y %H:%M:%S %Z", tm);
vpn_progress(vpninfo, PRG_INFO,
_("Session authentication will expire at %s\n"),