[Pam-developers] [PATCH] pam_loginuid: log significant loginuid write errors

Dmitry V. Levin ldv at altlinux.org
Mon Jan 27 14:20:18 UTC 2014


Any comments?

On Sun, Jan 19, 2014 at 06:56:49PM +0400, Dmitry V. Levin wrote:
> * modules/pam_loginuid/pam_loginuid.c (set_loginuid): Log those errors
> during /proc/self/loginuid update that are not ignored.
> ---
>  modules/pam_loginuid/pam_loginuid.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/modules/pam_loginuid/pam_loginuid.c b/modules/pam_loginuid/pam_loginuid.c
> index c476f7b..73c42f9 100644
> --- a/modules/pam_loginuid/pam_loginuid.c
> +++ b/modules/pam_loginuid/pam_loginuid.c
> @@ -75,8 +75,8 @@ static int set_loginuid(pam_handle_t *pamh, uid_t uid)
>  			rc = PAM_IGNORE;
>  		}
>  		if (rc != PAM_IGNORE) {
> -			pam_syslog(pamh, LOG_ERR,
> -				   "Cannot open /proc/self/loginuid: %m");
> +			pam_syslog(pamh, LOG_ERR, "Cannot open %s: %m",
> +				   "/proc/self/loginuid");
>  		}
>  		return rc;
>  	}
> @@ -88,8 +88,14 @@ static int set_loginuid(pam_handle_t *pamh, uid_t uid)
>  		goto done;	/* already correct */
>  	}
>  	if (lseek(fd, 0, SEEK_SET) == 0 && ftruncate(fd, 0) == 0 &&
> -	    pam_modutil_write(fd, loginuid, count) == count)
> +	    pam_modutil_write(fd, loginuid, count) == count) {
>  		rc = PAM_SUCCESS;
> +	} else {
> +		if (rc != PAM_IGNORE) {
> +			pam_syslog(pamh, LOG_ERR, "Error writing %s: %m",
> +				   "/proc/self/loginuid");
> +		}
> +	}
>   done:
>  	close(fd);
>  	return rc;

-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/pam-developers/attachments/20140127/da8e350d/attachment.sig>


More information about the Pam-developers mailing list