diff options
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/kvm.c | 33 | ||||
-rw-r--r-- | lib/libutil/login.c | 37 |
2 files changed, 30 insertions, 40 deletions
diff --git a/lib/libutil/kvm.c b/lib/libutil/kvm.c index 2c5de35dd0b8..5c9c856a5d92 100644 --- a/lib/libutil/kvm.c +++ b/lib/libutil/kvm.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kvm.c,v 1.8 1994/02/23 09:56:45 rgrimes Exp $ + * $Id: kvm.c,v 1.10 1994/03/22 21:56:48 davidg Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -291,35 +291,6 @@ kvm_nlist(nl) if ((db = dbm_open(dbname, O_RDONLY, 0)) == NULL) goto hard2; /* - * read version out of database - */ - bcopy("VERSION", symbuf, sizeof ("VERSION")-1); - key.dsize = (sizeof ("VERSION") - 1); - data = dbm_fetch(db, key); - if (data.dptr == NULL) - goto hard1; - bcopy(data.dptr, dbversion, data.dsize); - dbversionlen = data.dsize; - /* - * read version string from kernel memory - */ - bcopy("_version", symbuf, sizeof ("_version")-1); - key.dsize = (sizeof ("_version")-1); - data = dbm_fetch(db, key); - if (data.dptr == NULL) - goto hard1; - if (data.dsize != sizeof (struct nlist)) - goto hard1; - bcopy(data.dptr, &nbuf, sizeof (struct nlist)); - lseek(kmem, nbuf.n_value, 0); - if (read(kmem, kversion, dbversionlen) != dbversionlen) - goto hard1; - /* - * if they match, we win - otherwise do it the hard way - */ - if (bcmp(dbversion, kversion, dbversionlen) != 0) - goto hard1; - /* * getem from the database. */ win: @@ -513,7 +484,7 @@ again: } else eproc.e_tdev = NODEV; if (proc.p_wmesg) - kvm_read(proc.p_wmesg, eproc.e_wmesg, WMESGLEN); + kvm_read((char *)proc.p_wmesg, eproc.e_wmesg, WMESGLEN); (void) kvm_read(proc.p_vmspace, &eproc.e_vm, sizeof (struct vmspace)); eproc.e_xsize = eproc.e_xrssize = diff --git a/lib/libutil/login.c b/lib/libutil/login.c index b4e4d60f773d..fb87570b41ba 100644 --- a/lib/libutil/login.c +++ b/lib/libutil/login.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: login.c,v 1.2 1994/02/23 09:56:47 rgrimes Exp $ + * $Id: login.c,v 1.3 1994/04/07 17:47:36 ache Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -41,23 +41,42 @@ static char sccsid[] = "@(#)login.c 5.4 (Berkeley) 6/1/90"; #include <sys/file.h> #include <utmp.h> #include <stdio.h> +#include <unistd.h> +#include <ttyent.h> + +typedef struct utmp UTMP; void login(ut) - struct utmp *ut; + UTMP *ut; { register int fd; int tty; - off_t lseek(); + UTMP utmp; - tty = ttyslot(); - if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) { - (void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET); - (void)write(fd, (char *)ut, sizeof(struct utmp)); - (void)close(fd); + if ((fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) >= 0) { + if ((tty = ttyslot()) > 0) { + (void)lseek(fd, (long)(tty * sizeof(UTMP)), L_SET); + (void)write(fd, (char *)ut, sizeof(UTMP)); + (void)close(fd); + } else { + setttyent(); + for (tty = 0; getttyent(); tty++) + ; + endttyent(); + (void)lseek(fd, (long)(tty * sizeof(UTMP)), L_SET); + while (read(fd, (char *)&utmp, sizeof(UTMP)) == sizeof(UTMP)) { + if (!utmp.ut_name[0]) { + (void)lseek(fd, -(long)sizeof(UTMP), L_INCR); + break; + } + } + (void)write(fd, (char *)ut, sizeof(UTMP)); + (void)close(fd); + } } if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { - (void)write(fd, (char *)ut, sizeof(struct utmp)); + (void)write(fd, (char *)ut, sizeof(UTMP)); (void)close(fd); } } |