* include/cygwin/version.h: Bump API minor number for below export.

* 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.
This commit is contained in:
Christopher Faylor 2002-11-07 02:19:52 +00:00
parent 18cd62b7fb
commit 4248a1d7f8
5 changed files with 44 additions and 15 deletions

View File

@ -1,3 +1,18 @@
2002-11-06 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump API minor number for below export.
2002-11-06 Sergey Okhapkin <sos@prospect.com.ru>
* 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.
2002-11-05 Christopher Faylor <cgf@redhat.com>
* fhandler_serial.cc (fhandler_serial::ioctl): Don't try to figure out

View File

@ -621,6 +621,8 @@ putchar_unlocked
_putchar_unlocked = putchar_unlocked
puts
_puts = puts
pututline
_pututline = pututline
putw
_putw = putw
qsort

View File

@ -160,12 +160,13 @@ details. */
61: Export getc_unlocked, getchar_unlocked, putc_unlocked,
putchar_unlocked
62: Erroneously bumped.
63: Export pututline.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 62
#define CYGWIN_VERSION_API_MINOR 63
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@ -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, 2) == 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));
}

View File

@ -88,6 +88,7 @@ create_tty_master (int ttynum)
cygwin_gethostname (our_utmp.ut_host, sizeof (our_utmp.ut_host));
__small_sprintf (our_utmp.ut_line, "tty%d", ttynum);
our_utmp.ut_type = USER_PROCESS;
our_utmp.ut_pid = myself->pid;
myself->ctty = ttynum;
login (&our_utmp);
}