]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Allow FAXUSER environment variable to be set to a username which is not in the system...
authorPatrice Fournier <pfournier@ifax.com>
Fri, 18 May 2007 18:43:39 +0000 (18:43 +0000)
committerPatrice Fournier <pfournier@ifax.com>
Fri, 18 May 2007 18:43:39 +0000 (18:43 +0000)
util/FaxClient.c++

index 0cf1da128638dd1b557cc3f4b18a53d2e577c745..4ea185af8d52e67fe9d5d7b620bfc5adb7e9cf8a 100644 (file)
@@ -186,16 +186,16 @@ FaxClient::setupUserIdentity(fxStr& emsg)
        pwd = getpwuid(getuid());
     if (!pwd) {
        if (name)
-           emsg = fxStr::format("Can not locate FAXUSER password entry "
-               "(account name %s, uid %lu): %s", name, (u_long) getuid(),
-               strerror(errno));
-       else
+           userName = name;
+       else {
            emsg = fxStr::format("Can not locate your password entry "
                "(uid %lu): %s", (u_long) getuid(), strerror(errno));
-       return (false);
+           return (false);
+       }
     }
-    userName = pwd->pw_name;
-    if (pwd->pw_gecos && pwd->pw_gecos[0] != '\0') {
+    else
+       userName = pwd->pw_name;
+    if (pwd && pwd->pw_gecos && pwd->pw_gecos[0] != '\0') {
        senderName = pwd->pw_gecos;
        senderName.resize(senderName.next(0, '('));     // strip SysV junk
        u_int l = senderName.next(0, '&');
@@ -380,6 +380,10 @@ FaxClient::login(const char* user, fxStr& emsg)
        setupUserIdentity(emsg);
        user = userName;
     }
+    if (*user == '\0') {
+       emsg = "Malformed (null) username";
+       return (false);
+    }
     int n = command("USER %s", user);
     if (n == CONTINUE)
        n = command("PASS %s", getPasswd("Password:"));