Remove utmp warning on mac os x

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22947 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-04-10 09:47:28 +00:00
parent cc1564ec41
commit ae560bddd3

View File

@@ -77,7 +77,51 @@ shrink_hostname (const char *hostname,
}
}
void
#ifdef HAVE_UTMPX_H
void utmp_login(char *tty, const char *username, const char *hostname)
{
return;
}
#else
/* update utmp and wtmp - the BSD way */
static void prepare_utmp (struct utmp *, char *, const char *, const char *);
void utmp_login(char *tty, const char *username, const char *hostname)
{
struct utmp utmp;
int fd;
prepare_utmp (&utmp, tty, username, hostname);
#ifdef HAVE_SETUTENT
utmpname(_PATH_UTMP);
setutent();
pututline(&utmp);
endutent();
#else
#ifdef HAVE_TTYSLOT
{
int ttyno;
ttyno = ttyslot();
if (ttyno > 0 && (fd = open(_PATH_UTMP, O_WRONLY, 0)) >= 0) {
lseek(fd, (long)(ttyno * sizeof(struct utmp)), SEEK_SET);
write(fd, &utmp, sizeof(struct utmp));
close(fd);
}
}
#endif /* HAVE_TTYSLOT */
#endif /* HAVE_SETUTENT */
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
write(fd, &utmp, sizeof(struct utmp));
close(fd);
}
}
static void
prepare_utmp (struct utmp *utmp, char *tty,
const char *username, const char *hostname)
{
@@ -118,45 +162,4 @@ prepare_utmp (struct utmp *utmp, char *tty,
# endif
}
#ifdef HAVE_UTMPX_H
void utmp_login(char *tty, const char *username, const char *hostname)
{
return;
}
#else
/* update utmp and wtmp - the BSD way */
void utmp_login(char *tty, const char *username, const char *hostname)
{
struct utmp utmp;
int fd;
prepare_utmp (&utmp, tty, username, hostname);
#ifdef HAVE_SETUTENT
utmpname(_PATH_UTMP);
setutent();
pututline(&utmp);
endutent();
#else
#ifdef HAVE_TTYSLOT
{
int ttyno;
ttyno = ttyslot();
if (ttyno > 0 && (fd = open(_PATH_UTMP, O_WRONLY, 0)) >= 0) {
lseek(fd, (long)(ttyno * sizeof(struct utmp)), SEEK_SET);
write(fd, &utmp, sizeof(struct utmp));
close(fd);
}
}
#endif /* HAVE_TTYSLOT */
#endif /* HAVE_SETUTENT */
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
write(fd, &utmp, sizeof(struct utmp));
close(fd);
}
}
#endif /* !HAVE_UTMPX_H */