diff options
author | Christopher Faylor <me@cgf.cx> | 2002-11-07 03:48:00 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-11-07 03:48:00 +0000 |
commit | 04162cad52614d642c990b96c287a73e7c51a65f (patch) | |
tree | 7f6a420fcbb39d6e6cb814a68450a4a83a7b924c | |
parent | c94c19a41a2d8aa613624f9f408ef5a157bdf353 (diff) | |
download | newlib-unlabeled-1.231.4.zip newlib-unlabeled-1.231.4.tar.gz newlib-unlabeled-1.231.4.tar.bz2 |
* include/cygwin/version.h: Bump API minor number for below export.github/unlabeled-1.231.4unlabeled-1.231.4
* cygwin.din (pututline): New exported function.
* syscalls.cc (login): Use pututiline().
(setutent): Open utmp as read/write.
(endutent): Check if utmp file is open.
(utmpname): call endutent() to close current utmp file.
(getutid): Enable all cases, use strncmp() to compare ut_id fields.
(pututline): New.
* tty.cc (create_tty_master): Set ut_pid to current pid.
* fhandler.h (fhandler_serial::vmin_): Declare as size_t.
* fhandler_serial.cc (fhandler_serial::raw_read): Use correct type for
minchars.
(fhandler_serial::ioctl): Set errno if the ClearCommError fails.
(fhandler_serial::tcsetattr): Use correct value for vmin_.
(fhandler_serial::tcgetattr): Ditto.
* fhandler_socket.cc (fhandler_socket::recvmsg): Call if from == NULL
WSARecvFrom with fromlen = NULL.
-rw-r--r-- | winsup/cygwin/syscalls.cc | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index fd571eb..bfc45e7 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2427,15 +2427,8 @@ login (struct utmp *ut) { sigframe thisframe (mainthread); register int fd; - int currtty = ttyslot (); - if (currtty >= 0 && (fd = open (_PATH_UTMP, O_WRONLY | O_CREAT | O_BINARY, - 0644)) >= 0) - { - (void) lseek (fd, (long) (currtty * sizeof (struct utmp)), SEEK_SET); - (void) write (fd, (char *) ut, sizeof (struct utmp)); - (void) close (fd); - } + pututline (ut); if ((fd = open (_PATH_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0)) >= 0) { (void) write (fd, (char *) ut, sizeof (struct utmp)); @@ -2516,7 +2509,7 @@ setutent () sigframe thisframe (mainthread); if (utmp_fd == -2) { - utmp_fd = open (utmp_file, O_RDONLY); + utmp_fd = open (utmp_file, O_RDWR); } lseek (utmp_fd, 0, SEEK_SET); } @@ -2525,8 +2518,11 @@ extern "C" void endutent () { sigframe thisframe (mainthread); - close (utmp_fd); - utmp_fd = -2; + if (utmp_fd != -2) + { + close (utmp_fd); + utmp_fd = -2; + } } extern "C" void @@ -2538,6 +2534,7 @@ utmpname (_CONST char *file) debug_printf ("Invalid file"); return; } + endutent (); utmp_file = strdup (file); debug_printf ("New UTMP file: %s", utmp_file); } @@ -2563,7 +2560,6 @@ getutid (struct utmp *id) { switch (id->ut_type) { -#if 0 /* Not available in Cygwin. */ case RUN_LVL: case BOOT_TIME: case OLD_TIME: @@ -2571,12 +2567,11 @@ getutid (struct utmp *id) if (id->ut_type == utmp_data.ut_type) return &utmp_data; break; -#endif case INIT_PROCESS: case LOGIN_PROCESS: case USER_PROCESS: case DEAD_PROCESS: - if (id->ut_id == utmp_data.ut_id) + if (strncmp (id->ut_id, utmp_data.ut_id, UT_IDLEN) == 0) return &utmp_data; break; default: @@ -2602,3 +2597,18 @@ getutline (struct utmp *line) } return NULL; } + +extern "C" void +pututline (struct utmp *ut) +{ + sigframe thisframe (mainthread); + if (check_null_invalid_struct (ut)) + return; + setutent (); + struct utmp *u; + if ((u = getutid (ut))) + lseek (utmp_fd, -sizeof(struct utmp), SEEK_CUR); + else + lseek (utmp_fd, 0, SEEK_END); + (void) write (utmp_fd, (char *) ut, sizeof (struct utmp)); +} |