version 1.1.1.2, 2012/05/29 12:26:49
|
version 1.1.1.4, 2013/07/22 10:46:13
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 2011 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 2011-2013 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 17
|
Line 17
|
#include <config.h> |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
|
#include <sys/time.h> |
#include <sys/time.h> |
#include <sys/wait.h> |
#include <sys/wait.h> |
#include <stdio.h> |
#include <stdio.h> |
Line 53
|
Line 52
|
# include <ttyent.h> |
# include <ttyent.h> |
#endif |
#endif |
#include <fcntl.h> |
#include <fcntl.h> |
|
#include <signal.h> |
|
|
#include "sudo.h" |
#include "sudo.h" |
#include "sudo_exec.h" |
#include "sudo_exec.h" |
Line 275 utmp_slot(const char *line, int ttyfd)
|
Line 275 utmp_slot(const char *line, int ttyfd)
|
* doesn't take an argument. |
* doesn't take an argument. |
*/ |
*/ |
if ((sfd = dup(STDIN_FILENO)) == -1) |
if ((sfd = dup(STDIN_FILENO)) == -1) |
error(1, _("unable to save stdin")); | fatal(_("unable to save stdin")); |
if (dup2(ttyfd, STDIN_FILENO) == -1) |
if (dup2(ttyfd, STDIN_FILENO) == -1) |
error(1, _("unable to dup2 stdin")); | fatal(_("unable to dup2 stdin")); |
slot = ttyslot(); |
slot = ttyslot(); |
if (dup2(sfd, STDIN_FILENO) == -1) |
if (dup2(sfd, STDIN_FILENO) == -1) |
error(1, _("unable to restore stdin")); | fatal(_("unable to restore stdin")); |
close(sfd); |
close(sfd); |
|
|
debug_return_int(slot); |
debug_return_int(slot); |
Line 327 utmp_login(const char *from_line, const char *to_line,
|
Line 327 utmp_login(const char *from_line, const char *to_line,
|
} |
} |
} |
} |
utmp_fill(to_line, user, ut_old, &utbuf); |
utmp_fill(to_line, user, ut_old, &utbuf); |
|
#ifdef HAVE_FSEEKO |
|
if (fseeko(fp, slot * (off_t)sizeof(utbuf), SEEK_SET) == 0) { |
|
#else |
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) { |
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) { |
|
#endif |
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) |
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) |
rval = true; |
rval = true; |
} |
} |
Line 360 utmp_logout(const char *line, int status)
|
Line 364 utmp_logout(const char *line, int status)
|
# endif |
# endif |
utmp_settime(&utbuf); |
utmp_settime(&utbuf); |
/* Back up and overwrite record. */ |
/* Back up and overwrite record. */ |
|
#ifdef HAVE_FSEEKO |
|
if (fseeko(fp, (off_t)0 - (off_t)sizeof(utbuf), SEEK_CUR) == 0) { |
|
#else |
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) { |
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) { |
|
#endif |
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) |
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) |
rval = true; |
rval = true; |
} |
} |