diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-04-03 14:38:33 -0400 |
---|---|---|
committer | William Jon McCann <mccann@jhu.edu> | 2007-04-03 14:38:33 -0400 |
commit | bf9a5070a715f129e1182af149a46e55529edb61 (patch) | |
tree | 4119661ab4d4012e86f4c02cb691fd8de1b16121 /pam-ck-connector | |
parent | 8b1733abb942b4356485b4afcf1dc3bf04d1fedc (diff) | |
download | ConsoleKit2-bf9a5070a715f129e1182af149a46e55529edb61.tar.gz |
check for empty string as well as null values
Diffstat (limited to 'pam-ck-connector')
-rw-r--r-- | pam-ck-connector/pam-ck-connector.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pam-ck-connector/pam-ck-connector.c b/pam-ck-connector/pam-ck-connector.c index 5164c77..e57e80f 100644 --- a/pam-ck-connector/pam-ck-connector.c +++ b/pam-ck-connector/pam-ck-connector.c @@ -237,9 +237,6 @@ pam_sm_open_session (pam_handle_t *pamh, ret = PAM_IGNORE; - display_device = ""; - x11_display = ""; - remote_host_name = ""; is_local = TRUE; _parse_pam_args (pamh, flags, argc, argv); @@ -256,16 +253,21 @@ pam_sm_open_session (pam_handle_t *pamh, goto out; } - if (pam_get_user (pamh, &user, NULL) != PAM_SUCCESS || user == NULL) { + user = NULL; + res = pam_get_user (pamh, &user, NULL); + if (res != PAM_SUCCESS || user == NULL || user[0] == '\0') { ck_pam_syslog (pamh, LOG_ERR, "cannot determine username"); goto out; } - if (pam_get_item (pamh, PAM_TTY, (const void **) &display_device) != PAM_SUCCESS || display_device == NULL) { + display_device = NULL; + res = pam_get_item (pamh, PAM_TTY, (const void **) &display_device); + if (res != PAM_SUCCESS || display_device == NULL || display_device[0] == '\0') { ck_pam_syslog (pamh, LOG_ERR, "cannot determine display-device"); goto out; } + x11_display = NULL; /* interpret any tty with a colon as a DISPLAY */ if (strchr (display_device, ':') != NULL) { x11_display = display_device; @@ -275,7 +277,10 @@ pam_sm_open_session (pam_handle_t *pamh, display_device = ttybuf; } - if (pam_get_item (pamh, PAM_RHOST, (const void **) &s) == PAM_SUCCESS && s != NULL) { + remote_host_name = NULL; + s = NULL; + res = pam_get_item (pamh, PAM_RHOST, (const void **) &s); + if (res == PAM_SUCCESS && s != NULL && s[0] != '\0') { remote_host_name = s; if (opt_debug) { ck_pam_syslog (pamh, LOG_INFO, "using '%s' as remote-host-name", remote_host_name); |