From c07ebfa1e02d208ab12430e6791ea147bcfaf9c0 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 7 Dec 2006 00:25:46 +0100 Subject: Imported from util-linux-2.11b tarball. --- HISTORY | 38 +- INSTALL | 7 + MCONFIG | 5 +- Makefile | 3 +- VERSION | 2 +- configure | 34 +- disk-utils/fdformat.c | 2 +- disk-utils/fsck.minix.c | 10 +- disk-utils/mkfs.8 | 1 + disk-utils/mkfs.c | 4 +- disk-utils/mkswap.c | 10 +- disk-utils/setfdprm.c | 2 +- fdisk/Makefile | 2 +- fdisk/cfdisk.c | 55 +- fdisk/fdisk.c | 151 +- fdisk/fdisk.h | 3 +- fdisk/fdiskbsdlabel.c | 19 +- fdisk/fdisksgilabel.c | 50 +- fdisk/fdisksgilabel.h | 18 +- fdisk/fdisksunlabel.c | 15 +- fdisk/i386_sys_types.c | 3 + games/banner.c | 2 +- getopt-1.1.0a/Changelog | 2 +- getopt-1.1.0a/getopt.c | 2 +- hwclock/clock-ppc.c | 2 +- hwclock/cmos.c | 15 +- hwclock/hwclock.8 | 52 +- hwclock/kd.c | 2 +- hwclock/rtc.c | 2 +- kbd/Makefile | 25 - kbd/README | 2 - kbd/README.clear | 7 - kbd/README.reset | 20 - kbd/clear | 2 - kbd/clear.1 | 31 - kbd/kbdrate.8 | 71 - kbd/kbdrate.c | 282 -- kbd/reset | 11 - lib/Makefile | 4 +- lib/env.c | 2 +- lib/pathnames.h | 18 +- lib/widechar.h | 8 + lib/xstrncpy.c | 9 + lib/xstrncpy.h | 1 + login-utils/Makefile | 20 +- login-utils/agetty.c | 31 +- login-utils/checktty.c | 18 +- login-utils/chfn.c | 6 +- login-utils/chsh.c | 2 +- login-utils/cryptocard.c | 2 +- login-utils/islocal.c | 2 +- login-utils/last.c | 43 +- login-utils/login.c | 160 +- login-utils/mesg.c | 2 +- login-utils/newgrp.c | 2 +- login-utils/passwd.c | 6 +- login-utils/setpwnam.h | 17 + login-utils/shutdown.c | 6 +- login-utils/simpleinit.c | 122 +- login-utils/ttymsg.c | 2 +- login-utils/vipw.c | 94 +- login-utils/wall.c | 10 +- misc-utils/Makefile | 7 +- misc-utils/cal.c | 2 +- misc-utils/ddate.c | 2 +- misc-utils/flushb.c | 5 + misc-utils/kill.1 | 79 +- misc-utils/kill.c | 25 +- misc-utils/logger.c | 2 +- misc-utils/look.c | 2 +- misc-utils/mcookie.c | 2 +- misc-utils/namei.c | 2 +- misc-utils/script.c | 2 +- misc-utils/setterm.c | 11 +- misc-utils/tsort.1 | 74 - misc-utils/tsort.c | 376 -- misc-utils/whereis.c | 2 +- misc-utils/write.c | 13 +- mount/Makefile | 10 +- mount/fstab.5 | 10 +- mount/fstab.c | 12 +- mount/lomount.c | 11 +- mount/mntent.c | 2 +- mount/mount.8 | 130 +- mount/mount.c | 31 +- mount/mount_by_label.c | 2 +- mount/mount_constants.h | 9 +- mount/mount_guess_fstype.c | 91 +- mount/mount_guess_rootdev.c | 2 +- mount/nfs.5 | 3 + mount/nfsmount.c | 256 +- mount/sundries.c | 2 +- mount/swapon.c | 2 +- mount/umount.c | 4 +- po/ChangeLog | 2 +- po/Makefile | 5 +- po/POTFILES.in | 24 +- po/cat-id-tbl.c | 3769 ++++++++--------- po/cs.po | 18 +- po/da.po | 9404 ++++++++++++++++++++++--------------------- po/de.po | 18 +- po/es.po | 18 +- po/fr.po | 18 +- po/it.po | 18 +- po/ja.po | 18 +- po/nl.po | 18 +- po/pt_BR.po | 18 +- sys-utils/ctrlaltdel.c | 2 +- sys-utils/cytune.c | 2 +- sys-utils/dmesg.c | 2 +- sys-utils/ipcrm.c | 2 +- sys-utils/ipcs.c | 46 +- sys-utils/rdev.c | 2 +- sys-utils/readprofile.1 | 16 +- sys-utils/readprofile.c | 335 +- sys-utils/renice.c | 2 +- sys-utils/setsid.c | 22 +- sys-utils/tunelp.c | 2 +- text-utils/Makefile | 27 +- text-utils/README.clear | 7 + text-utils/README.reset | 20 + text-utils/clear | 2 + text-utils/clear.1 | 31 + text-utils/col.c | 2 +- text-utils/colcrt.c | 2 +- text-utils/colrm.c | 2 +- text-utils/column.c | 2 +- text-utils/hexdump.c | 2 +- text-utils/hexsyntax.c | 2 +- text-utils/more.1 | 3 +- text-utils/more.c | 11 +- text-utils/odsyntax.c | 2 +- text-utils/parse.c | 2 +- text-utils/reset | 11 + text-utils/rev.c | 2 +- text-utils/ul.c | 2 +- 136 files changed, 8044 insertions(+), 8603 deletions(-) delete mode 100644 kbd/Makefile delete mode 100644 kbd/README delete mode 100644 kbd/README.clear delete mode 100644 kbd/README.reset delete mode 100755 kbd/clear delete mode 100644 kbd/clear.1 delete mode 100644 kbd/kbdrate.8 delete mode 100644 kbd/kbdrate.c delete mode 100755 kbd/reset create mode 100644 lib/xstrncpy.c create mode 100644 lib/xstrncpy.h create mode 100644 misc-utils/flushb.c delete mode 100644 misc-utils/tsort.1 delete mode 100644 misc-utils/tsort.c create mode 100644 text-utils/README.clear create mode 100644 text-utils/README.reset create mode 100755 text-utils/clear create mode 100644 text-utils/clear.1 create mode 100755 text-utils/reset diff --git a/HISTORY b/HISTORY index 265d02f3e..92d6b89ec 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,39 @@ +util-linux 2.11b: + +* Danish messages (Claus Hindsgaul) +* umount: mips does not support umount2 (Christoph Martin) +* fdisk: tiny fix +* mount.8: adfs options documented, xfs corrected + +util-linux 2.11a: + +* tsort: deleted - it is part of GNU textutils 2.0 +* mount: fix rootdev() (Richard Kettlewell) +* mount: fix gid of mtab file +* mount: try /proc/filesystems after /etc/filesystems if the latter ends in "*" +* fdisk: added a few system types + +util-linux 2.11: + +* Jump to 2.11 to note that libc-4.5.26 is no longer supported, + and we require libc-4.6.27 (since now snprintf is used). + Also, kbdrate has now been removed. Find it in kbd-1.05. + Added -D_FILE_OFFSET_BITS=64 to CFLAGS. +* Danish messages (Claus Hindsgaul) +* fdisk: avoid loop in case of extended without logical +* ipcs: corrected interchanged report on msg_rtime/msg_stime (Arun Kumar U) +* kill: updated manpage +* last: very much faster with mmap (Marek Zelem) +* login: Applied PAM patch by David MacKenzie +* login: do a setsid in the child (Erik Troan) +* mount: make "mount 192.168.1.8:/ /a -o bg" work again (Bjoern Voigt) +* mount: added constant MS_MOVE +* readprofile: added -M option, updated manpage (Andrew Morton) +* setsid: fork when it would fail otherwise (John Fremlin) +* simpleinit: updated (Richard Gooch et al.) +* vipw: also offer to edit shadow file (Erik Troan) +* xfs docs (Nathan Scott) + util-linux 2.10s: * Danish messages (Claus Hindsgaul) @@ -275,7 +311,7 @@ util-linux 2.9n: util-linux 2.9m: -* Added national language support (misiek@misiek.eu.org) +* Added national language support (misiek@pld.ORG.PL) * minor improvements in mount, fdisk, cfdisk, agetty, more util-linux 2.9l: diff --git a/INSTALL b/INSTALL index fe3359fca..4b47ba0d0 100644 --- a/INSTALL +++ b/INSTALL @@ -65,6 +65,13 @@ Warnings like :30: warning: this is the location of the previous definition are caused by the libc/kernel combination. +Warnings like + setterm.c:805: warning: passing arg 1 of `tigetstr' discards qualifiers + from pointer target type + login.c:979: warning: passing arg 1 of `putenv' discards qualifiers + from pointer target type +are caused by bad ncurses or glibc header files. + All such warnings are harmless. There should be no compilation errors. diff --git a/MCONFIG b/MCONFIG index a97f259d8..e53915ab5 100644 --- a/MCONFIG +++ b/MCONFIG @@ -80,10 +80,6 @@ HAVE_RESET=yes # sln also comes with libc and glibc. HAVE_SLN=no -# If HAVE_TSORT is set to "yes", then tsort won't be installed. -# GNU textutils 2.0 includes tsort. -HAVE_TSORT=no - # If HAVE_FDUTILS is set to "yes", then setfdprm won't be installed. HAVE_FDUTILS=no @@ -168,6 +164,7 @@ INSTALLSUID= $(INSTALL) -m $(SUIDMODE) -o root CFLAGS := $(CFLAGS) $(OPT) -I$(LIB) $(WARNFLAGS) \ $(CURSESFLAGS) $(SLANGFLAGS) \ + -D_FILE_OFFSET_BITS=64 \ -DSBINDIR=\"$(SBINDIR)\" \ -DUSRSBINDIR=\"$(USRSBINDIR)\" \ -DLOGDIR=\"$(LOGDIR)\" \ diff --git a/Makefile b/Makefile index 0d68c8333..0cca84336 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,7 @@ SUBDIRS=po \ fdisk \ hwclock \ sys-utils \ - text-utils \ - kbd + text-utils .PHONEY: all install clean now all: defines.h diff --git a/VERSION b/VERSION index 77744d0d2..5b0f3c855 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.10s +2.11b diff --git a/configure b/configure index fd5ab6422..8de131a80 100755 --- a/configure +++ b/configure @@ -9,7 +9,7 @@ # H3. For kbd_rate.c: does exist? # H4. For nls.h: do we have ? # H5. For cal.c: do we have ? -# H6. For mkswap.c: do we have ? +# H6. For mkswap.c: do we have or ? # H7. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have ? # # Existence of functions: @@ -18,6 +18,7 @@ # F3. For agetty.c: is getdomainname() available? # F4. For hwclock/kd.c: do we have nanosleep()? # F5. For mkswap.c: do we have personality()? +# F6. For agetty.c: is updwtmp() available? # # 1. For sys-utils/cytune.c: do we need ? # 2. For cfdisk, setterm, more, ul: do we have ncurses? How installed? @@ -114,11 +115,13 @@ if ./testincl "langinfo.h"; then fi # -# H6. For mkswap.c: do we have ? +# H6. For mkswap.c: do we have or ? # -if ./testincl "asm/page.h"; then +if ./testincl "sys/user.h"; then + echo "#define HAVE_sys_user_h" >> defines.h +else if ./testincl "asm/page.h"; then echo "#define HAVE_asm_page_h" >> defines.h -fi +fi fi # # H7. For nfsmount.h: do we have ? @@ -234,6 +237,29 @@ else fi rm -f conftest conftest.c +# +# F6. For agetty.c: is updwtmp() available? +# +echo ' +#include +#include +main(int a, char **v){ + struct utmp ut; + memset (&ut, 0, sizeof(ut)); + if (a == -1) /* false */ + updwtmp("/nowhere/wtmp", &ut); + exit(0); +} +' > conftest.c +eval $compile +if test -s conftest && ./conftest 2>/dev/null; then + echo "#define HAVE_updwtmp" >> defines.h + echo "You have updwtmp()" +else + echo "You don't have updwtmp()" +fi +rm -f conftest conftest.c + # # 1. cytune.c may need struct tq_struct diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c index b4aec0076..cfbb455ce 100644 --- a/disk-utils/fdformat.c +++ b/disk-utils/fdformat.c @@ -1,6 +1,6 @@ /* fdformat.c - Low-level formats a floppy disk - Werner Almesberger */ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * 1999-03-20 Arnaldo Carvalho de Melo & - more i18n/nls translatable strings marked diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index 1f040eb52..e36594aa2 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -62,7 +62,7 @@ * 06.11.96 - Added v2 code submitted by Joerg Dorchain, but written by * Andreas Schwab. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * @@ -211,10 +211,10 @@ die(const char *str) { */ static void print_current_name(void) { - int i=0; + int i = 0; - while (i - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * */ @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) } sprintf(newpath, "%s:%s\n", SEARCH_PATH, oldpath); putenv(newpath); - sprintf(progname, PROGNAME, fstype); + snprintf(progname, sizeof(progname), PROGNAME, fstype); argv[--optind] = progname; if (verbose) { diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 6bd96d904..ea2ec20dc 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -26,7 +26,7 @@ * V1_MAX_PAGES fixes, jj, 990325. * sparc64 fixes, jj, 000219. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * */ @@ -41,12 +41,16 @@ #include #include "nls.h" +/* Try to get PAGE_SIZE from libc or kernel includes */ +#ifdef HAVE_sys_user_h + /* Note: says: for gdb only */ +#include /* for PAGE_SIZE and PAGE_SHIFT */ +#else #ifdef HAVE_asm_page_h #include /* for PAGE_SIZE and PAGE_SHIFT */ /* we also get PAGE_SIZE via getpagesize() */ -/* recent glibc systems also define this in */ #endif - +#endif #ifndef _IO /* pre-1.3.45 */ diff --git a/disk-utils/setfdprm.c b/disk-utils/setfdprm.c index 958f98c16..aee8a4d16 100644 --- a/disk-utils/setfdprm.c +++ b/disk-utils/setfdprm.c @@ -1,7 +1,7 @@ /* setfdprm.c - Sets user-provided floppy disk parameters, re-activates autodetection and switches diagnostic messages. */ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ diff --git a/fdisk/Makefile b/fdisk/Makefile index 3a851fa02..ad774c888 100644 --- a/fdisk/Makefile +++ b/fdisk/Makefile @@ -43,7 +43,7 @@ else endif endif -cfdisk: cfdisk.o llseek.o i386_sys_types.o +cfdisk: cfdisk.o llseek.o i386_sys_types.o $(LIB)/xstrncpy.o ifeq "$(HAVE_SLANG)" "yes" $(CC) $(LDFLAGS) $^ -o $@ $(LIBSLANG) else diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 055046d7b..8b5643e62 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -76,6 +76,7 @@ #include #include "nls.h" +#include "xstrncpy.h" #include "common.h" #if defined(__GNUC__) || defined(HAS_LONG_LONG) @@ -516,23 +517,26 @@ print_warning(char *s) { static void fatal(char *s, int ret) { - char *err = _("FATAL ERROR"); + char *err1 = _("FATAL ERROR"); + char *err2 = _("Press any key to exit cfdisk"); if (curses_started) { - char *str = xmalloc(strlen(s) + strlen(err) + 10); - /* snprintf does not compile on all libc's */ - sprintf(str, "%s: %s", err, s); + char *str = xmalloc(strlen(s) + strlen(err1) + strlen(err2) + 10); + + sprintf(str, "%s: %s", err1, s); if (strlen(str) > COLS) - str[COLS] = 0; + str[COLS] = 0; mvaddstr(WARNING_START, (COLS-strlen(str))/2, str); - sprintf(str, _("Press any key to exit cfdisk")); + sprintf(str, "%s", err2); + if (strlen(str) > COLS) + str[COLS] = 0; mvaddstr(WARNING_START+1, (COLS-strlen(str))/2, str); putchar(BELL); /* CTRL-G */ refresh(); (void)getch(); die_x(ret); } else { - fprintf(stderr, "%s: %s\n", err, s); + fprintf(stderr, "%s: %s\n", err1, s); exit(ret); } } @@ -1034,17 +1038,15 @@ menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, /* Print available buttons */ move( y, x ); clrtoeol(); - for( i = 0; menuItems[i].key; i++ ) - { + for( i = 0; menuItems[i].key; i++ ) { char buff[20]; int lenName; const char *mi; /* Search next available button */ while( menuItems[i].key && !strchr(available, menuItems[i].key) ) - { i++; - } + if( !menuItems[i].key ) break; /* No more menu items */ /* If selected item is not available and we have bypassed it, @@ -1066,15 +1068,13 @@ menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, print_warning(_("Menu item too long. Menu may look odd.")); #endif if (lenName >= sizeof(buff)) { /* truncate ridiculously long string */ - strncpy( buff, mi, sizeof(buff)-1); - buff[sizeof(buff)-1] = 0; - } else - if( menuType & MENU_BUTTON ) - sprintf( buff, "[%*s%-*s]", (itemLength - lenName) / 2, "", - (itemLength - lenName + 1) / 2 + lenName, mi ); - else - sprintf( buff, "%*s%-*s", (itemLength - lenName) / 2, "", - (itemLength - lenName + 1) / 2 + lenName, mi ); + xstrncpy( buff, mi, sizeof(buff)); + } else { + snprintf(buff, sizeof(buff), + (menuType & MENU_BUTTON) ? "[%*s%-*s]" : "%*s%-*s", + (itemLength - lenName) / 2, "", + (itemLength - lenName + 1) / 2 + lenName, mi); + } mvaddstr( y, x, buff ); /* Lowlight after selected item */ @@ -1339,7 +1339,7 @@ new_part(int i) { else print_warning(_("!!! Internal error !!!")); - sprintf(def, "%.2f", num_sects/sectors_per_MB); + snprintf(def, sizeof(def), "%.2f", num_sects/sectors_per_MB); mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, _("Size (in MB): ")); if ((len = get_string(response, LINE_LENGTH, def)) <= 0 && len != GS_DEFAULT) @@ -1548,7 +1548,6 @@ fill_p_info(void) { add_part(i, p->sys_ind, p->boot_ind, ((bs <= sectors) ? 0 : bs), bs + bsz - 1, ((bs <= sectors) ? bs : 0), 1, &errmsg)) { - /* avoid snprintf - it does not exist on ancient systems */ char *bad = _("Bad primary partition"); char *msg = (char *) xmalloc(strlen(bad) + strlen(errmsg) + 30); sprintf(msg, "%s %d: %s", bad, i, errmsg); @@ -1579,7 +1578,6 @@ fill_p_info(void) { logical_sectors[logical-1], logical_sectors[logical-1] + bs + bsz - 1, bs, 1, &errmsg)) { - /* avoid snprintf */ char *bad = _("Bad logical partition"); char *msg = (char *) xmalloc(strlen(bad) + strlen(errmsg) + 30); sprintf(msg, "%s %d: %s", bad, i-1, errmsg); @@ -1751,8 +1749,10 @@ write_part_table(void) { for (i = 0; i < num_parts; i++) if (IS_PRIMARY(i) && p_info[i].flags == ACTIVE_FLAG) ct++; - if (ct != 1) - print_warning(_("Not precisely one primary partition is bootable. DOS MBR cannot boot this.")); + if (ct == 0) + print_warning(_("No primary partitions are marked bootable. DOS MBR cannot boot this.")); + if (ct > 1) + print_warning(_("More than one primary partition is marked bootable. DOS MBR cannot boot this.")); } static void @@ -1762,7 +1762,7 @@ fp_printf(FILE *fp, char *format, ...) { int y, x; va_start(args, format); - vsprintf(buf, format, args); + vsnprintf(buf, sizeof(buf), format, args); va_end(args); if (fp == NULL) { @@ -1818,7 +1818,8 @@ print_raw_table(void) { if (to_file) { if ((fp = fopen(fname, "w")) == NULL) { char errstr[LINE_LENGTH]; - sprintf(errstr, _("Cannot open file '%s'"), fname); + snprintf(errstr, sizeof(errstr), + _("Cannot open file '%s'"), fname); print_warning(errstr); return; } diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 969bf8790..a439f3273 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -66,7 +66,7 @@ static void delete_partition(int i); }) -#define LINE_LENGTH 80 +#define LINE_LENGTH 800 #define pt_offset(b, n) ((struct partition *)((b) + 0x1be + \ (n) * sizeof(struct partition))) #define sector(s) ((s) & 0x3f) @@ -222,25 +222,31 @@ void fatal(enum failure why) { " ...\n"); break; case unable_to_open: - sprintf(error, _("Unable to open %s\n"), disk_device); + snprintf(error, sizeof(error), + _("Unable to open %s\n"), disk_device); break; case unable_to_read: - sprintf(error, _("Unable to read %s\n"), disk_device); + snprintf(error, sizeof(error), + _("Unable to read %s\n"), disk_device); break; case unable_to_seek: - sprintf(error, _("Unable to seek on %s\n"),disk_device); + snprintf(error, sizeof(error), + _("Unable to seek on %s\n"),disk_device); break; case unable_to_write: - sprintf(error, _("Unable to write %s\n"), disk_device); + snprintf(error, sizeof(error), + _("Unable to write %s\n"), disk_device); break; case ioctl_error: - sprintf(error, _("BLKGETSIZE ioctl failed on %s\n"), + snprintf(error, sizeof(error), + _("BLKGETSIZE ioctl failed on %s\n"), disk_device); break; case out_of_memory: message = _("Unable to allocate any more memory\n"); break; - default: message = _("Fatal error\n"); + default: + message = _("Fatal error\n"); } fputc('\n', stderr); @@ -282,7 +288,7 @@ read_pte(int fd, int pno, uint offset) { pe->changed = 0; pe->part_table = pe->ext_pointer = NULL; } - + static unsigned int get_partition_start(struct pte *pe) { return pe->offset + get_start_sect(pe->part_table); @@ -623,17 +629,18 @@ read_extended(int ext) { for (i = 0; i < 4; i++, p++) if (get_nr_sects(p)) { if (IS_EXTENDED (p->sys_ind)) { if (pe->ext_pointer) - fprintf(stderr, _("Warning: extra link" - " pointer in partition table " - "%d\n"), partitions + 1); + fprintf(stderr, + _("Warning: extra link " + "pointer in partition table" + " %d\n"), partitions + 1); else pe->ext_pointer = p; } else if (p->sys_ind) { if (pe->part_table) fprintf(stderr, - _("Warning: ignoring extra data " - "in partition table %d\n"), - partitions + 1); + _("Warning: ignoring extra " + "data in partition table" + " %d\n"), partitions + 1); else pe->part_table = p; } @@ -662,7 +669,8 @@ read_extended(int ext) { for (i = 4; i < partitions; i++) { struct pte *pe = &ptes[i]; - if (!get_nr_sects(pe->part_table)) { + if (!get_nr_sects(pe->part_table) && + (partitions > 5 || ptes[4].part_table->sys_ind)) { printf("omitting empty partition (%d)\n", i+1); delete_partition(i); goto remove; /* numbering changed */ @@ -682,10 +690,10 @@ create_doslabel(void) { sun_nolabel(); /* otherwise always recognised as sun */ sgi_nolabel(); /* otherwise always recognised as sgi */ + for (i = 510-64; i < 510; i++) + MBRbuffer[i] = 0; write_part_table_flag(MBRbuffer); - for (i = 0; i < 4; i++) - if (ptes[i].part_table) - clear_partition(ptes[i].part_table); + extended_offset = 0; set_all_unchanged(); set_changed(0); get_boot(create_empty); @@ -969,8 +977,8 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) static char *ms = NULL; static int mslen = 0; - if (!ms || strlen(mesg)+50 > mslen) { - mslen = strlen(mesg)+100; + if (!ms || strlen(mesg)+100 > mslen) { + mslen = strlen(mesg)+200; if (!(ms = realloc(ms,mslen))) fatal(out_of_memory); } @@ -979,9 +987,11 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) default_ok = 0; if (default_ok) - sprintf(ms, _("%s (%d-%d, default %d): "), mesg, low, high, dflt); + snprintf(ms, mslen, _("%s (%d-%d, default %d): "), + mesg, low, high, dflt); else - sprintf(ms, "%s (%d-%d): ", mesg, low, high); + snprintf(ms, mslen, "%s (%d-%d): ", + mesg, low, high); while (1) { int use_default = default_ok; @@ -1137,12 +1147,15 @@ delete_partition(int i) { } if (!q->sys_ind && i > 4) { + /* the last one in the chain - just delete */ --partitions; --i; clear_partition(ptes[i].ext_pointer); ptes[i].changed = 1; } else { + /* not the last one - further ones will be moved down */ if (i > 4) { + /* delete this link in the chain */ p = ptes[i-1].ext_pointer; p->boot_ind = 0; p->head = q->head; @@ -1156,6 +1169,7 @@ delete_partition(int i) { set_nr_sects(p, get_nr_sects(q)); ptes[i-1].changed = 1; } else if (partitions > 5) { /* 5 will be moved to 4 */ + /* the first logical in a longer chain */ struct pte *pe = &ptes[5]; if(pe->part_table) /* prevent SEGFAULT */ @@ -1173,6 +1187,7 @@ delete_partition(int i) { i++; } } else + /* the only logical: clear only */ clear_partition(ptes[i].part_table); } } @@ -1185,12 +1200,12 @@ change_sysid(void) { origsys = sys = get_sysid(i); - if (!sys && !sgi_label) + if (!sys && !sgi_label && !sun_label) printf(_("Partition %d does not exist yet!\n"), i + 1); else while (1) { sys = read_hex (get_sys_types()); - if (!sys && !sgi_label) { + if (!sys && !sgi_label && !sun_label) { printf(_("Type 0 means free space to many systems\n" "(but not to Linux). Having partitions of\n" "type 0 is probably unwise. You can delete\n" @@ -1460,7 +1475,7 @@ list_table(int xtra) { check_consistency(p, i); } } - + /* Is partition table in disk order? It need not be, but... */ /* partition table entries are not checked for correct order if this is a sgi, sun or aix labeled disk... */ @@ -1543,7 +1558,7 @@ verify(void) { int i, j; uint total = 1; uint first[partitions], last[partitions]; - struct partition *p = part_table[0]; + struct partition *p; if (warn_geometry()) return; @@ -1642,7 +1657,7 @@ add_partition(int n, int sys) { for (i = 0; i < partitions; i++) first[i] = (cround(first[i]) - 1) * units_per_sector; - sprintf(mesg, _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); do { temp = start; for (i = 0; i < partitions; i++) { @@ -1701,8 +1716,9 @@ add_partition(int n, int sys) { if (cround(start) == cround(limit)) { stop = limit; } else { - sprintf(mesg, _("Last %s or +size or +sizeM or +sizeK"), - str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), + _("Last %s or +size or +sizeM or +sizeK"), + str_units(SINGULAR)); stop = read_int(cround(start), cround(limit), cround(limit), cround(start), mesg); if (display_in_cyl_units) { @@ -1785,16 +1801,17 @@ new_partition(void) { add_logical(); else printf(_("You must delete some partition and add " - "an extended partition first\n")); + "an extended partition first\n")); } else { char c, line[LINE_LENGTH]; - sprintf(line, _("Command action\n %s\n p primary " - "partition (1-4)\n"), extended_offset ? - _("l logical (5 or over)") : _("e extended")); - while (1) + snprintf(line, sizeof(line), + _("Command action\n %s\n p primary " + "partition (1-4)\n"), extended_offset ? + _("l logical (5 or over)") : _("e extended")); + while (1) { if ((c = tolower(read_char(line))) == 'p') { add_partition(get_partition(0, 4), - LINUX_NATIVE); + LINUX_NATIVE); return; } else if (c == 'l' && extended_offset) { @@ -1803,13 +1820,13 @@ new_partition(void) { } else if (c == 'e' && !extended_offset) { add_partition(get_partition(0, 4), - EXTENDED); + EXTENDED); return; } else printf(_("Invalid partition number " - "for type `%c'\n"), c); - + "for type `%c'\n"), c); + } } } @@ -2052,7 +2069,7 @@ is_ide_cdrom(char *device) { if (strncmp("/dev/hd", device, 7)) return 0; - sprintf(buf, "/proc/ide/%s/media", device+5); + snprintf(buf, sizeof(buf), "/proc/ide/%s/media", device+5); procf = fopen(buf, "r"); if (procf != NULL && fgets(buf, sizeof(buf), procf)) return !strncmp(buf, "cdrom", 5); @@ -2068,34 +2085,34 @@ is_ide_cdrom(char *device) { static void try(char *device, int user_specified) { disk_device = device; - if (!setjmp(listingbuf)) { - if (!user_specified) - if (is_ide_cdrom(device)) + if (setjmp(listingbuf)) + return; + if (!user_specified) + if (is_ide_cdrom(device)) + return; + if ((fd = open(disk_device, type_open)) >= 0) { + if (get_boot(try_only) < 0) { + list_disk_geometry(); + if (aix_label) return; - if ((fd = open(disk_device, type_open)) >= 0) { - if (get_boot(try_only) < 0) { - list_disk_geometry(); - if (aix_label) - return; - if (btrydev(device) < 0) - fprintf(stderr, - _("Disk %s doesn't contain a valid " - "partition table\n"), device); - close(fd); - } else { - close(fd); - list_table(0); - if (!sun_label && partitions > 4) - delete_partition(ext_index); - } + if (btrydev(device) < 0) + fprintf(stderr, + _("Disk %s doesn't contain a valid " + "partition table\n"), device); + close(fd); } else { - /* Ignore other errors, since we try IDE - and SCSI hard disks which may not be - installed on the system. */ - if(errno == EACCES) { - fprintf(stderr, _("Cannot open %s\n"), device); - return; - } + close(fd); + list_table(0); + if (!sun_label && partitions > 4) + delete_partition(ext_index); + } + } else { + /* Ignore other errors, since we try IDE + and SCSI hard disks which may not be + installed on the system. */ + if(errno == EACCES) { + fprintf(stderr, _("Cannot open %s\n"), device); + return; } } } @@ -2115,13 +2132,13 @@ tryprocpt(void) { } while (fgets(line, sizeof(line), procpt)) { - if (sscanf (line, " %d %d %d %[^\n]\n", + if (sscanf (line, " %d %d %d %[^\n ]", &ma, &mi, &sz, ptname) != 4) continue; for(s = ptname; *s; s++); if (isdigit(s[-1])) continue; - sprintf(devname, "/dev/%s", ptname); + snprintf(devname, sizeof(devname), "/dev/%s", ptname); try(devname, 0); } } diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h index 868251dff..449f8dc3c 100644 --- a/fdisk/fdisk.h +++ b/fdisk/fdisk.h @@ -15,6 +15,8 @@ #define LINUX_SWAP 0x82 #define LINUX_NATIVE 0x83 #define LINUX_EXTENDED 0x85 +#define LINUX_LVM 0x8e +#define LINUX_RAID 0xfd #define IS_EXTENDED(i) \ ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED) @@ -67,7 +69,6 @@ extern int fd, extern uint display_in_cyl_units, units_per_sector; extern void change_units(void); -extern struct partition *part_table[]; extern void fatal(enum failure why); extern void get_geometry(int fd, struct geom *); extern int get_boot(enum action what); diff --git a/fdisk/fdiskbsdlabel.c b/fdisk/fdiskbsdlabel.c index 0f3c68136..80efc36e6 100644 --- a/fdisk/fdiskbsdlabel.c +++ b/fdisk/fdiskbsdlabel.c @@ -273,14 +273,14 @@ xbsd_new_part (void) end = xbsd_dlabel.d_secperunit - 1; #endif - sprintf (mesg, _("First %s"), str_units(SINGULAR)); + snprintf (mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); begin = read_int (bsd_cround (begin), bsd_cround (begin), bsd_cround (end), 0, mesg); if (display_in_cyl_units) begin = (begin - 1) * xbsd_dlabel.d_secpercyl; - sprintf (mesg, _("Last %s or +size or +sizeM or +sizeK"), + snprintf (mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); end = read_int (bsd_cround (begin), bsd_cround (end), bsd_cround (end), bsd_cround (begin), mesg); @@ -517,13 +517,13 @@ xbsd_write_bootstrap (void) else dkbasename = "wd"; - printf (_("Bootstrap: %sboot -> boot%s (%s): "), dkbasename, dkbasename, dkbasename); - if (read_line ()) - { + printf (_("Bootstrap: %sboot -> boot%s (%s): "), + dkbasename, dkbasename, dkbasename); + if (read_line ()) { line_ptr[strlen (line_ptr)-1] = '\0'; dkbasename = line_ptr; } - sprintf (path, "%s/%sboot", bootdir, dkbasename); + snprintf (path, sizeof(path), "%s/%sboot", bootdir, dkbasename); if (!xbsd_get_bootstrap (path, disklabelbuffer, (int) xbsd_dlabel.d_secsize)) return; @@ -534,15 +534,14 @@ xbsd_write_bootstrap (void) /* The disklabel will be overwritten by 0's from bootxx anyway */ bzero (d, sizeof (struct xbsd_disklabel)); - sprintf (path, "%s/boot%s", bootdir, dkbasename); + snprintf (path, sizeof(path), "%s/boot%s", bootdir, dkbasename); if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize], (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) return; e = d + sizeof (struct xbsd_disklabel); for (p=d; p < e; p++) - if (*p) - { + if (*p) { fprintf (stderr, _("Bootstrap overlaps with disk label!\n")); exit ( EXIT_FAILURE ); } @@ -588,7 +587,7 @@ xbsd_get_part_index (int max) char prompt[256]; char l; - sprintf (prompt, _("Partition (a-%c): "), 'a' + max - 1); + snprintf (prompt, sizeof(prompt), _("Partition (a-%c): "), 'a' + max - 1); do l = tolower (read_char (prompt)); while (l < 'a' || l > 'a' + max - 1); diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c index 97e6c595a..09296905d 100644 --- a/fdisk/fdisksgilabel.c +++ b/fdisk/fdisksgilabel.c @@ -76,23 +76,25 @@ isinfreelist( int b ) { * end of free blocks section */ struct systypes sgi_sys_types[] = { - {SGI_VOLHDR, N_("SGI volhdr")}, - {0x01, N_("SGI trkrepl")}, - {0x02, N_("SGI secrepl")}, - {SGI_SWAP, N_("SGI raw")}, - {0x04, N_("SGI bsd")}, - {0x05, N_("SGI sysv")}, - {ENTIRE_DISK, N_("SGI volume")}, - {SGI_EFS, N_("SGI efs")}, - {0x08, N_("SGI lvol")}, - {0x09, N_("SGI rlvol")}, - {0x0a, N_("SGI xfs")}, - {0x0b, N_("SGI xlvol")}, - {0x0c, N_("SGI rxlvol")}, - {LINUX_SWAP, N_("Linux swap")}, - {LINUX_NATIVE,N_("Linux native")}, - {0x8e, N_("Linux LVM")}, - {0, NULL } + {SGI_VOLHDR, N_("SGI volhdr")}, + {0x01, N_("SGI trkrepl")}, + {0x02, N_("SGI secrepl")}, + {SGI_SWAP, N_("SGI raw")}, + {0x04, N_("SGI bsd")}, + {0x05, N_("SGI sysv")}, + {ENTIRE_DISK, N_("SGI volume")}, + {SGI_EFS, N_("SGI efs")}, + {0x08, N_("SGI lvol")}, + {0x09, N_("SGI rlvol")}, + {SGI_XFS, N_("SGI xfs")}, + {SGI_XFSLOG, N_("SGI xfslog")}, + {SGI_XLV, N_("SGI xlv")}, + {SGI_XVM, N_("SGI xvm")}, + {LINUX_SWAP, N_("Linux swap")}, + {LINUX_NATIVE, N_("Linux native")}, + {LINUX_LVM, N_("Linux LVM")}, + {LINUX_RAID, N_("Linux RAID")}, + {0, NULL } }; static inline unsigned short @@ -357,7 +359,7 @@ create_sgiinfo(void) /* I keep SGI's habit to write the sgilabel to the second block */ sgilabel->directory[0].vol_file_start = SSWAP32( 2 ); sgilabel->directory[0].vol_file_size = SSWAP32( sizeof( sgiinfo ) ); - strncpy( sgilabel->directory[0].vol_file_name, "sgilabel",8 ); + strncpy( sgilabel->directory[0].vol_file_name, "sgilabel", 8 ); } sgiinfo * fill_sgiinfo(void); @@ -681,7 +683,7 @@ sgi_add_partition( int n, int sys ) printf(_("You got a partition overlap on the disk. Fix it first!\n")); return; } - sprintf(mesg, _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); for(;;) { if(sys == SGI_VOLUME) { last = sgi_get_lastblock(); @@ -708,7 +710,7 @@ sgi_add_partition( int n, int sys ) } else break; } - sprintf(mesg, _(" Last %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _(" Last %s"), str_units(SINGULAR)); last = read_int(scround(first), scround(last)-1, scround(last)-1, scround(first), mesg)+1; if (display_in_cyl_units) @@ -768,8 +770,12 @@ create_sgilabel(void) memset(MBRbuffer, 0, sizeof(MBRbuffer)); sgilabel->magic = SSWAP32(SGI_LABEL_MAGIC); sgilabel->boot_part = SSWAP16(0); - sgilabel->swap_part = SSWAP16(1); strncpy( - sgilabel->boot_file , "/unix\0\0\0\0\0\0\0\0\0\0\0", 16 ); + sgilabel->swap_part = SSWAP16(1); + + /* sizeof(sgilabel->boot_file) = 16 > 6 */ + memset(sgilabel->boot_file, 0, 16); + strcpy(sgilabel->boot_file, "/unix"); + sgilabel->devparam.skew = (0); sgilabel->devparam.gap1 = (0); sgilabel->devparam.gap2 = (0); diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h index a0c3a1056..cdad01a9c 100644 --- a/fdisk/fdisksgilabel.h +++ b/fdisk/fdisksgilabel.h @@ -31,10 +31,18 @@ struct device_parameter { /* 48 bytes */ unsigned short xylogics_writecont; }; +#define SGI_VOLHDR 0x00 +/* 1 and 2 were used for drive types no longer supported by SGI */ +#define SGI_SWAP 0x03 +/* 4 and 5 were for filesystem types SGI haven't ever supported on MIPS CPUs */ #define SGI_VOLUME 0x06 #define SGI_EFS 0x07 -#define SGI_SWAP 0x03 -#define SGI_VOLHDR 0x00 +#define SGI_LVOL 0x08 +#define SGI_RLVOL 0x09 +#define SGI_XFS 0x0a +#define SGI_XFSLOG 0x0b +#define SGI_XLV 0x0c +#define SGI_XVM 0x0d #define ENTIRE_DISK SGI_VOLUME /* * controller flags @@ -48,19 +56,19 @@ struct device_parameter { /* 48 bytes */ #define ENABLE_CMDTAGQ 0x40 typedef struct { - unsigned int magic; /* expect SGI_LABEL_MAGIC */ + unsigned int magic; /* expect SGI_LABEL_MAGIC */ unsigned short boot_part; /* active boot partition */ unsigned short swap_part; /* active swap partition */ unsigned char boot_file[16]; /* name of the bootfile */ struct device_parameter devparam; /* 1 * 48 bytes */ struct volume_directory { /* 15 * 16 bytes */ - unsigned char vol_file_name[8]; /* an character array */ + unsigned char vol_file_name[8]; /* a character array */ unsigned int vol_file_start; /* number of logical block */ unsigned int vol_file_size; /* number of bytes */ } directory[15]; struct sgi_partition { /* 16 * 12 bytes */ unsigned int num_sectors; /* number of blocks */ - unsigned int start_sector; /* sector must be cylinder aligned */ + unsigned int start_sector; /* must be cylinder aligned */ unsigned int id; } partitions[16]; unsigned int csum; diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c index f96cb0b15..2a36852a5 100644 --- a/fdisk/fdisksunlabel.c +++ b/fdisk/fdisksunlabel.c @@ -348,10 +348,11 @@ void create_sunlabel(void) puts(_("You may change all the disk params from the x menu")); } - sprintf(sunlabel->info, "%s%s%s cyl %d alt %d hd %d sec %d", - p ? p->vendor : "", - (p && *p->vendor) ? " " : "", - p ? p->model : (floppy ? _("3,5\" floppy") : _("Linux custom")), + snprintf(sunlabel->info, sizeof(sunlabel->info), + "%s%s%s cyl %d alt %d hd %d sec %d", + p ? p->vendor : "", (p && *p->vendor) ? " " : "", + p ? p->model + : (floppy ? _("3,5\" floppy") : _("Linux custom")), cylinders, SSWAP16(sunlabel->nacyl), heads, sectors); sunlabel->ntrks = SSWAP16(heads); @@ -514,7 +515,7 @@ add_sun_partition(int n, int sys) { return; } } - sprintf(mesg, _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); for (;;) { if (whole_disk) first = read_int(0, 0, 0, 0, mesg); @@ -549,7 +550,9 @@ and is of type `Whole disk'\n"); if (starts[i] > first && starts[i] < stop) stop = starts[i]; } - sprintf(mesg, _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), + _("Last %s or +size or +sizeM or +sizeK"), + str_units(SINGULAR)); if (whole_disk) last = read_int(scround(stop2), scround(stop2), scround(stop2), 0, mesg); diff --git a/fdisk/i386_sys_types.c b/fdisk/i386_sys_types.c index 3e5f0f1b7..ce01b189a 100644 --- a/fdisk/i386_sys_types.c +++ b/fdisk/i386_sys_types.c @@ -76,12 +76,15 @@ struct systypes i386_sys_types[] = { {0xda, N_("Non-FS data")}, {0xdb, N_("CP/M / CTOS / ...")},/* CP/M or Concurrent CP/M or Concurrent DOS or CTOS */ + {0xde, N_("Dell Utility")}, /* Dell PowerEdge Server utilities */ {0xe1, N_("DOS access")}, /* DOS access or SpeedStor 12-bit FAT extended partition */ {0xe3, N_("DOS R/O")}, /* DOS R/O or SpeedStor */ {0xe4, N_("SpeedStor")}, /* SpeedStor 16-bit FAT extended partition < 1024 cyl. */ {0xeb, N_("BeOS fs")}, + {0xee, N_("EFI GPT")}, /* Intel EFI GUID Partition Table */ + {0xef, N_("EFI (FAT-12/16/32)")},/* Intel EFI System Partition */ {0xf1, N_("SpeedStor")}, {0xf4, N_("SpeedStor")}, /* SpeedStor large partition */ {0xf2, N_("DOS secondary")}, /* DOS 3.3+ secondary */ diff --git a/games/banner.c b/games/banner.c index 31206a433..e8f7bf9ea 100644 --- a/games/banner.c +++ b/games/banner.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ diff --git a/getopt-1.1.0a/Changelog b/getopt-1.1.0a/Changelog index e144bb0f8..339c5bb16 100644 --- a/getopt-1.1.0a/Changelog +++ b/getopt-1.1.0a/Changelog @@ -1,5 +1,5 @@ 20000630: Ported the Native Language Support patches from util-linux - They are written by Arkadiusz Mi¶kiewicz + They are written by Arkadiusz Mi¶kiewicz 20000627: Bumped up version number to 1.0.6 20000627: A few manpage tweaks 20000616: Introduced DESTDIR and directory creation in the Makefile. diff --git a/getopt-1.1.0a/getopt.c b/getopt-1.1.0a/getopt.c index 86efe2f84..e52c14903 100644 --- a/getopt-1.1.0a/getopt.c +++ b/getopt-1.1.0a/getopt.c @@ -34,7 +34,7 @@ * No important changes * Version 1.1.0: Tue Jun 30 2000 * Added NLS support (partly written by Arkadiusz Mikiewicz - * ) + * ) */ #include diff --git a/hwclock/clock-ppc.c b/hwclock/clock-ppc.c index 6d8969adb..b73d0ad8b 100644 --- a/hwclock/clock-ppc.c +++ b/hwclock/clock-ppc.c @@ -241,7 +241,7 @@ main (int argc, char **argv ) /* If we are in MkLinux do not even bother trying to set the clock */ if(!access("/proc/osfmach3/version", R_OK)) - { // We're running MkLinux + { /* We're running MkLinux */ if ( readit | writeit | setit | adjustit ) printf("You must change the clock setting in MacOS.\n"); exit(0); diff --git a/hwclock/cmos.c b/hwclock/cmos.c index 4fc82d798..94153dea0 100644 --- a/hwclock/cmos.c +++ b/hwclock/cmos.c @@ -61,10 +61,17 @@ int inb(int c){ return 0; } #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) +/* The epoch. + Unix uses 1900 as epoch for a struct tm, and 1970 for a time_t. + But what was written to CMOS? + Digital DECstations use 1928 - this is on a mips + Digital Unix uses 1952. + Windows NT uses 1980. + The ARC console expects to boot Windows NT and uses 1980. + (But a Ruffian uses 1900, just like SRM.) + It is reported that ALPHA_PRE_V1_2_SRM_CONSOLE uses 1958. */ #define TM_EPOCH 1900 -int cmos_epoch = 1900; /* 1980 for an alpha in ARC console time */ - /* One also sees 1952 (Digital Unix) - and 1958 (ALPHA_PRE_V1_2_SRM_CONSOLE) */ +int cmos_epoch = 1900; /* Martin Ostermann writes: The problem with the Jensen is twofold: First, it has the clock at a @@ -576,7 +583,7 @@ get_permissions_cmos(void) { } else { rc = i386_iopl(3); if (rc == -2) { - fprintf(stderr, _("I failed to get permission because I didnt try.\n")); + fprintf(stderr, _("I failed to get permission because I didn't try.\n")); } else if (rc != 0) { rc = errno; fprintf(stderr, _("%s is unable to get I/O port access: " diff --git a/hwclock/hwclock.8 b/hwclock/hwclock.8 index 7e4106d45..07c4f8cdb 100644 --- a/hwclock/hwclock.8 +++ b/hwclock/hwclock.8 @@ -53,7 +53,7 @@ what function to perform: .TP .B \-\-show Read the Hardware Clock and print the time on Standard Output. -The time is always in local time, even if you keep your Hardware Clock +The time shown is always in local time, even if you keep your Hardware Clock in Coordinated Universal Time. See the .B \-\-utc option. @@ -130,9 +130,12 @@ option. .B \-\-epoch=year Specifies the year which is the beginning of the Hardware Clock's epoch. I.e. the number of years into AD to which a zero value in the -Hardware Clock's year counter refers. +Hardware Clock's year counter refers. It is used together with +the \-\-setepoch option to set the kernel's idea of the epoch of the +Hardware Clock, or otherwise to specify the epoch for use with +direct ISA access. -For example, +For example, on a Digital Unix machine: .sp .I hwclock --setepoch --epoch=1952 @@ -226,48 +229,37 @@ whenever it finds your Hardware Clock set to 1994 or 1995. .TP .B \-\-srm +This option is equivalent to +.B \-\-epoch=1900 +and is used to specify the most common epoch on Alphas +with SRM console. .TP .B \-\-arc +This option is equivalent to +.B \-\-epoch=1980 +and is used to specify the most common epoch on Alphas +with ARC console (but Ruffians have epoch 1900). .TP .B \-\-jensen .TP .B \-\-funky\-toy -These options all tell -.B hwclock -what kind of Alpha machine you have. They -are invalid if you don't have an Alpha and shouldn't be necessary if you -do, because +These two options specify what kind of Alpha machine you have. They +are invalid if you don't have an Alpha and are usually unnecessary +if you do, because .B hwclock should be able to determine by itself what it's running on, at least when .I /proc -is mounted. These options make it possible for -.B hwclock -to work even when -its environment does not conform to its expectations and thus it cannot -accurately determine what sort of system it is running on. If you think -hwclock is incorrectly determining the system's characteristics, try -running with the -.B \-\-debug -option to see what conclusions the program is -reaching and how. If you find you need one of these options to make -.B hwclock -work, contact the +is mounted. +(If you find you need one of these options to make .B hwclock -maintainer to see if the program can be improved to detect your system -automatically. +work, contact the maintainer to see if the program can be improved +to detect your system automatically. Output of `hwclock --debug' +and `cat /proc/cpuinfo' may be of interest.) .B \-\-jensen means you are running on a Jensen model. -.B \-\-arc -means your machine uses epoch 1980 in its hardware clock, as is commonly -the case for machines on ARC console (but Ruffians have epoch 1900). - -.B \-\-srm -means your machine uses epoch 1900 in its hardware clock, as is commonly -the case for machines on SRM console. - .B \-\-funky\-toy means that on your machine, one has to use the UF bit instead of the UIP bit in the Hardware Clock to detect a time transition. "Toy" diff --git a/hwclock/kd.c b/hwclock/kd.c index fd4fdd5a1..a2f313f6d 100644 --- a/hwclock/kd.c +++ b/hwclock/kd.c @@ -124,7 +124,7 @@ set_hardware_clock_kd(const struct tm *new_broken_time) { t.wday = new_broken_time->tm_wday; if (ioctl(con_fd, KDSHWCLK, &t ) == -1) { - outsyserr(_("ioctl() to open /dev/tty1 failed")); + outsyserr(_("ioctl KDSHWCLK failed")); exit(1); } return 0; diff --git a/hwclock/rtc.c b/hwclock/rtc.c index 2874bfa14..06ac4360f 100644 --- a/hwclock/rtc.c +++ b/hwclock/rtc.c @@ -290,7 +290,7 @@ get_permissions_rtc(void) { } static struct clock_ops rtc = { - "/dev/rtc interface to clock", + RTC_DEV " interface to clock", get_permissions_rtc, read_hardware_clock_rtc, set_hardware_clock_rtc, diff --git a/kbd/Makefile b/kbd/Makefile deleted file mode 100644 index 30bfb0e80..000000000 --- a/kbd/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# Makefile -- Makefile for util-linux Linux utilities -# -include ../make_include -include ../MCONFIG - -# Where to put man pages? - -MAN8= kbdrate.8 - -# Where to put binaries? -# See the "install" rule for the links. . . - -SBIN= kbdrate - -all: $(SBIN) - -kbdrate: kbdrate.o - -install: all - $(INSTALLDIR) $(SBINDIR) $(MAN8DIR) - $(INSTALLBIN) $(SBIN) $(SBINDIR) - $(INSTALLMAN) $(MAN8) $(MAN8DIR) - -clean: - -rm -f *.o *~ core $(SBIN) diff --git a/kbd/README b/kbd/README deleted file mode 100644 index 97ca5bdee..000000000 --- a/kbd/README +++ /dev/null @@ -1,2 +0,0 @@ -This stuff belongs in the kbd package and will disappear here. -It is left for a while - version in kbd* and here will be identical. diff --git a/kbd/README.clear b/kbd/README.clear deleted file mode 100644 index 7684132de..000000000 --- a/kbd/README.clear +++ /dev/null @@ -1,7 +0,0 @@ -RedHat and SuSE take the program clear from ncurses. - A 20KB program equivalent to "tput clear". - -Slackware uses the script. - -So, both versions will behave identically, and -Slackware saves 20 KB. diff --git a/kbd/README.reset b/kbd/README.reset deleted file mode 100644 index 8060d265d..000000000 --- a/kbd/README.reset +++ /dev/null @@ -1,20 +0,0 @@ -RedHat and SuSE take the program reset from ncurses, - where reset is a name for the program tset. - It is approximately equivalent to - stty sane; tputs rs1; tputs rs2; tputs rf - with `tputs rf' replaced by `tputs if' when there is an - init_file but no reset_file. In the comments it wonders - whether also sending rs3, rmacs, rmul, rmm might be a good idea. - -Slackware uses the small script given here. - The part `echo -e \\033c' is the canonical reset of the kernel - console status, and is equivalent to `tputs rs1' for a linux - terminal. - -So, both versions are approximately the same. - - -[A disadvantage of `echo -e \\033c' might be that it is potentially -wrong on a non-vt100, non-xterm, non-linux terminal. -An advantage is that there are terminfo entries for xterm around -that only use rs1=^O as reset, and then \Ec is much better.] diff --git a/kbd/clear b/kbd/clear deleted file mode 100755 index 73d1ebe1c..000000000 --- a/kbd/clear +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -tput clear diff --git a/kbd/clear.1 b/kbd/clear.1 deleted file mode 100644 index 9d2082304..000000000 --- a/kbd/clear.1 +++ /dev/null @@ -1,31 +0,0 @@ -.\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu) -.\" May be distributed under the GNU General Public License -.TH CLEAR 1 "10 October 1993" "Linux 0.99" "Linux Programmer's Manual" -.SH NAME -clear \- clear terminal screen -.SH SYNOPSIS -.BR clear -.SH DESCRIPTION -.B clear -calls -.BR tput (1) -with the -.I clear -argument. This causes -.B tput -to attempt to clear the screen checking the data in -.I /etc/termcap -(for the GNU or BSD -.BR tput ) -or in the terminfo database -(for the -.B ncurses -.BR tput ) -and sending the appropriate sequence to the terminal. This command can be -redirected to clear the screen of some other terminal. -.SH "SEE ALSO" -.BR reset (1), -.BR stty (1), -.BR tput (1) -.SH AUTHOR -Rik Faith (faith@cs.unc.edu) diff --git a/kbd/kbdrate.8 b/kbd/kbdrate.8 deleted file mode 100644 index e0fd890ff..000000000 --- a/kbd/kbdrate.8 +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright 1992, 1994 Rickard E. Faith (faith@cs.unc.edu) -.\" May be distributed under the GNU General Public License -.\" Updated Wed Jun 22 21:09:43 1994, faith@cs.unc.edu -.\" -.TH KBDRATE 8 "22 June 1994" "Linux 1.1.19" "Linux Programmer's Manual" -.SH NAME -kbdrate \- reset the keyboard repeat rate and delay time -.SH SYNOPSIS -.B "kbdrate [ \-s ] [ \-r" -rate -.B "] [ \-d" -delay -.B ] -.SH DESCRIPTION -.B kbdrate -is used to change the keyboard repeat rate and delay time. The delay -is the amount of time that a key must be depressed before it will start to -repeat. - -Using -.B kbdrate -without any options will reset the repeat rate to 10.9 characters per second (cps) -and the delay to 250 milliseconds (ms) for Intel- and M68K-based systems. -These are the IBM defaults. On SPARC-based systems it will reset the repeat rate -to 5 cps and the delay to 200 ms. - -.SH OPTIONS -.TP -.B \-s -Silent. No messages are printed. -.TP -.BI \-r " rate" -Change the keyboard repeat rate to -.I rate -cps. For Intel-based systems, the allowable range is from 2.0 to 30.0 cps. -Only certain, specific values are possible, and the program will select the -nearest possible value to the one specified. The possible values are given, -in characters per second, as follows: 2.0, 2.1, 2.3, 2.5, 2.7, 3.0, 3.3, 3.7, -4.0, 4.3, 4.6, 5.0, 5.5, 6.0, 6.7, 7.5, 8.0, 8.6, 9.2, 10.0, 10.9, 12.0, 13.3, -15.0, 16.0, 17.1, 18.5, 20.0, 21.8, 24.0, 26.7, 30.0. -For SPARC-based systems, the allowable range is from 0 (no repeat) to 50 cps. -.TP -.BI \-d " delay" -Change the delay to -.I delay -milliseconds. -For Intel-based systems, the allowable range is from 250 to 1000 ms, -in 250 ms steps. For SPARC systems, possible values are between 10 ms and 1440 ms, -in 10 ms steps. -.TP -.B \-V -Display a version number and exit. -.SH BUGS -Not all keyboards support all rates. -.PP -Not all keyboards have the rates mapped in the same way. -.PP -Setting the repeat rate on the Gateway AnyKey keyboard does not work. If -someone with a Gateway figures out how to program the keyboard, please send -mail to util-linux@math.uio.no. -.PP -All this is very architecture dependent. -Nowadays -.B kbdrate -first tries the KDKBDREP and KIOCSRATE ioctls. -(The former usually works on an m68k machine, the latter for SPARC.) -When these ioctls fail an ioport interface as on i386 is assumed. -.SH FILES -.I /etc/rc.local -.br -.I /dev/port diff --git a/kbd/kbdrate.c b/kbd/kbdrate.c deleted file mode 100644 index df116e1e0..000000000 --- a/kbd/kbdrate.c +++ /dev/null @@ -1,282 +0,0 @@ -/* -From: faith@cs.unc.edu (Rik Faith) -Subject: User mode keyboard rate changer -Date: 27 Apr 92 13:44:26 GMT - -I put together this program, called kbdrate.c, which will reset the keyboard -repeat rate and delay in user mode. The program must have read/write -access to /dev/port, so if /dev/port is only read/writeable by group port, -then kbdrate must run setgid to group port (for example). - -The "rate" is the rate in characters per second - -The "delay" is the amount of time the key must remain depressed before it -will start to repeat. - -Usage examples: - -kbdrate set rate to IBM default (10.9 cps, 250ms delay) -kbdrate -r 30.0 set rate to 30 cps and delay to 250ms -kbdrate -r 20.0 -s set rate to 20 cps (delay 250ms) -- don't print message -kbdrate -r 0 -d 0 set rate to 2.0 cps and delay to 250 ms - -I find it useful to put kbdrate in my /etc/rc file so that the keyboard -rate is set to something that I find comfortable at boot time. This sure -beats rebuilding the kernel! - - - kbdrate.c -- Set keyboard typematic rate (and delay) - Created: Thu Apr 23 12:24:30 1992 - Author: Rickard E. Faith, faith@cs.unc.edu - - Copyright 1992 Rickard E. Faith. Distributed under the GPL. - This program comes with ABSOLUTELY NO WARRANTY. - Usage: kbdrate [-r rate] [-d delay] [-s] - Rate can range from 2.0 to 30.0 (units are characters per second) - Delay can range from 250 to 1000 (units are milliseconds) - -s suppressed message - Compiles under gcc 2.1 for Linux (tested with the pre-0.96 kernel) - - Wed Jun 22 21:35:43 1994, faith@cs.unc.edu: - Changed valid_rates per suggestion by Andries.Brouwer@cwi.nl. - Wed Jun 22 22:18:29 1994, faith@cs.unc.edu: - Added patch for AUSTIN notebooks from John Bowman - (bowman@hagar.ph.utexas.edu) - - Linux/68k modifications by Roman Hodek - (Roman.Hodek@informatik.uni-erlangen.de): - - Reading/writing the Intel I/O ports via /dev/port is not the - English way... Such hardware dependant stuff can never work on - other architectures. - - Linux/68k has an new ioctl for setting the keyboard repeat rate - and delay. Both values are counted in msecs, the kernel will do - any rounding to values possible with the underlying hardware. - - kbdrate now first tries if the KDKBDREP ioctl is available. If it - is, it is used, else the old method is applied. - - 1999-02-22 Arkadiusz Mi¶kiewicz - - added Native Language Support - - 1999-03-17 - Linux/SPARC modifications by Jeffrey Connell : - It seems that the KDKBDREP ioctl is not available on this platform. - However, Linux/SPARC has its own ioctl for this, with yet another - different measurement system. Thus, try for KIOCSRATE, too. - -*/ - -#include -#include -#include -#include -#include -#include - -#include "../defines.h" -#ifdef HAVE_kd_h -#include -#endif -#ifdef __sparc__ -#include -#include -#endif - -#include "nls.h" - -static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, - 133, 120, 109, 100, 92, 86, 80, 75, 67, - 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, - 25, 23, 21, 20 }; -#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int )) - -static int valid_delays[] = { 250, 500, 750, 1000 }; -#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int )) - -static int -KDKBDREP_ioctl_ok(double rate, int delay, int silent) { -#ifdef KDKBDREP - /* This ioctl is defined in but is not - implemented anywhere - must be in some m68k patches. */ - struct kbd_repeat kbdrep_s; - - /* don't change, just test */ - kbdrep_s.rate = -1; - kbdrep_s.delay = -1; - if (ioctl( 0, KDKBDREP, &kbdrep_s )) { - if (errno == EINVAL) - return 0; - perror( "ioctl(KDKBDREP)" ); - exit( 1 ); - } - - /* do the change */ - if (rate == 0) /* switch repeat off */ - kbdrep_s.rate = 0; - else - kbdrep_s.rate = 1000.0 / rate; /* convert cps to msec */ - if (kbdrep_s.rate < 1) - kbdrep_s.rate = 1; - kbdrep_s.delay = delay; - if (kbdrep_s.delay < 1) - kbdrep_s.delay = 1; - - if (ioctl( 0, KDKBDREP, &kbdrep_s )) { - perror( "ioctl(KDKBDREP)" ); - exit( 1 ); - } - - /* report */ - if (kbdrep_s.rate == 0) - rate = 0; - else - rate = 1000.0 / (double) kbdrep_s.rate; - - if (!silent) - printf( _("Typematic Rate set to %.1f cps (delay = %d ms)\n"), - rate, kbdrep_s.delay ); - - return 1; /* success! */ - -#else /* no KDKBDREP */ - return 0; -#endif /* KDKBDREP */ -} - -static int -KIOCSRATE_ioctl_ok(double rate, int delay, int silent) { -#ifdef KIOCSRATE - struct kbd_rate kbdrate_s; - int fd; - - fd = open("/dev/kbd", O_RDONLY); - if (fd == -1) { - perror( "open(/dev/kbd)" ); - exit( 1 ); - } - - kbdrate_s.rate = (int) (rate + 0.5); /* must be integer, so round up */ - kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */ - if (kbdrate_s.rate > 50) - kbdrate_s.rate = 50; - - if (ioctl( fd, KIOCSRATE, &kbdrate_s )) { - perror( "ioctl(KIOCSRATE)" ); - exit( 1 ); - } - close( fd ); - - if (!silent) - printf( "Typematic Rate set to %d cps (delay = %d ms)\n", - kbdrate_s.rate, kbdrate_s.delay * 1000 / HZ ); - - return 1; -#else /* no KIOCSRATE */ - return 0; -#endif /* KIOCSRATE */ -} - -int main( int argc, char **argv ) -{ -#ifdef __sparc__ - double rate = 5.0; /* Default rate */ - int delay = 200; /* Default delay */ -#else - double rate = 10.9; /* Default rate */ - int delay = 250; /* Default delay */ -#endif - int value = 0x7f; /* Maximum delay with slowest rate */ - /* DO NOT CHANGE this value */ - int silent = 0; - int fd; - char data; - int c; - int i; - extern char *optarg; - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - - while ( (c = getopt( argc, argv, "r:d:svVh?" )) != EOF ) { - switch (c) { - case 'r': - rate = atof( optarg ); - break; - case 'd': - delay = atoi( optarg ); - break; - case 's': - silent = 1; - break; - case 'v': - case 'V': - fprintf( stderr, "util-linux %s kbdrate\n", UTIL_LINUX_VERSION); - exit(0); - case 'h': - case '?': - fprintf( stderr, - _("Usage: kbdrate [-V] [-s] [-r rate] [-d delay]\n")); - exit(0); - } - } - - if(KDKBDREP_ioctl_ok(rate, delay, silent)) /* m68k? */ - return 0; - - if(KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */ - return 0; - - - /* The ioport way */ - - for (i = 0; i < RATE_COUNT; i++) - if (rate * 10 >= valid_rates[i]) { - value &= 0x60; - value |= i; - break; - } - - - for (i = 0; i < DELAY_COUNT; i++) - if (delay <= valid_delays[i]) { - value &= 0x1f; - value |= i << 5; - break; - } - - if ( (fd = open( "/dev/port", O_RDWR )) < 0) { - perror( _("Cannot open /dev/port") ); - exit( 1 ); - } - - do { - lseek( fd, 0x64, 0 ); - read( fd, &data, 1 ); - } while ((data & 2) == 2 ); /* wait */ - - lseek( fd, 0x60, 0 ); - data = 0xf3; /* set typematic rate */ - write( fd, &data, 1 ); - - do { - lseek( fd, 0x64, 0 ); - read( fd, &data, 1 ); - } while ((data & 2) == 2 ); /* wait */ - - lseek( fd, 0x60, 0 ); - sleep( 1 ); - write( fd, &value, 1 ); - - close( fd ); - - if (!silent) - printf( _("Typematic Rate set to %.1f cps (delay = %d ms)\n"), - valid_rates[value & 0x1f] / 10.0, - valid_delays[ (value & 0x60) >> 5 ] ); - - return 0; -} diff --git a/kbd/reset b/kbd/reset deleted file mode 100755 index fb9834db2..000000000 --- a/kbd/reset +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -stty sane -tput clear -tput rmacs -tput rmm -tput rmso -tput rmul -tput rs1 -tput rs2 -tput rs3 -echo -e \\033c diff --git a/lib/Makefile b/lib/Makefile index 31e953ce7..986280c4b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,7 @@ include ../make_include include ../MCONFIG -all: err.o my_reboot.o setproctitle.o env.o carefulputc.o +all: err.o my_reboot.o setproctitle.o env.o carefulputc.o xstrncpy.o err.o: err.c @@ -13,6 +13,8 @@ setproctitle.o: setproctitle.h carefulputc.o: carefulputc.h +xstrncpy.o: xstrncpy.h + .PHONY: clean clean: -rm -f *.o *~ core diff --git a/lib/env.c b/lib/env.c index 69c821c2d..dffb371f0 100644 --- a/lib/env.c +++ b/lib/env.c @@ -1,7 +1,7 @@ /* * Security checks of enviroment * Added from shadow-utils package - * by Arkadiusz Mi¶kiewicz + * by Arkadiusz Mi¶kiewicz * */ diff --git a/lib/pathnames.h b/lib/pathnames.h index 672b58e92..9f10a16d4 100644 --- a/lib/pathnames.h +++ b/lib/pathnames.h @@ -26,7 +26,7 @@ * What is the history of these six, and related defines? ------------------------------------------------------------------------ -_PATH_UTMP and UTMP_FILE and UTMP_FILENAME: +_PATH_UTMP and UTMP_FILE and UTMP_FILENAME /etc/utmp > /var/adm/utmp > /var/run/utmp. Traditionally we have /etc/utmp. In we have /etc/utmp, but since 4.6.0 /var/adm/utmp @@ -34,7 +34,7 @@ and since 5.0.9 (and in glibc2) /var/run/utmp. In login/pathnames.h we have /etc/utmp, but since 4.6.6 /var/adm/utmp. In UTMP_FILE is defined as /etc/utmp, but in 4.6.* as _PATH_UTMP. -_PATH_WTMP and WTMP_FILE and WTMP_FILENAME: +_PATH_WTMP and WTMP_FILE and WTMP_FILENAME /etc/wtmp > /usr/adm/wtmp > /var/adm/wtmp > /var/log/wtmp. Traditionally we have /etc/wtmp. In we have /usr/adm/wtmp, but since 4.5.13 /var/adm/wtmp, @@ -43,21 +43,21 @@ In login/pathnames.h. we have /etc/wtmp, but since 4.6.6 /var/adm/wtmp. In WTMP_FILE is defined as /usr/adm/wtmp, but in 4.5.* as /var/adm/wtmp, and in 4.6.* as _PATH_WTMP. -_PATH_DEFPATH) +_PATH_DEFPATH Long ago this was ".:/bin:/usr/bin". In libc 4.4.1-4.4.4 have "/usr/bin:/bin" and libc 4.5.21-5.4.23 have "/usr/local/bin:/usr/bin:/bin:." and libc 5.4.38-5.4.46 have "/usr/local/bin:/usr/bin:/bin". In login/pathnames.h libc4 and libc5 have "/usr/local/bin:/bin:/usr/bin:." -_PATH_DEFPATH_ROOT) +_PATH_DEFPATH_ROOT Long ago this was identical to _PATH_DEFPATH. In no definition is present before libc 4.5.13. Libc 4.5.13 has "/bin:/usr/bin:/etc" Libc 4.5.14-5.4.46 have "/sbin:/bin:/usr/sbin:/usr/bin" In login/pathnames.h libc4 and libc5 have "/bin:/usr/bin:/etc" -_PATH_LASTLOG) +_PATH_LASTLOG /etc/lastlog > /usr/adm/lastlog > /var/adm/lastlog > /var/log/lastlog. Traditionally we have /etc/lastlog. In libc 4.4.1-4.5.12 have /usr/adm/lastlog, 4.5.13 and @@ -65,7 +65,7 @@ later have /var/adm/lastlog. In paths.h all libc5 and glibc2 versions have /var/log/lastlog. In login/pathnames.h all libc4 and libc5 versions have /usr/adm/lastlog. -_PATH_MAILDIR) +_PATH_MAILDIR /usr/spool/mail > /var/spool/mail > /var/mail. Traditionally we have /usr/spool/mail. In we have /usr/spool/mail, but since libc 4.5.13 /var/spool/mail. @@ -140,6 +140,12 @@ Libc5 and glibc 2.0-2.1 have /var/spool/mail, but glibc 2.1.1 has /var/mail. #define _PATH_GROUP "/etc/group" #define _PATH_GTMP "/etc/gtmp" #define _PATH_GTMPTMP "/etc/gtmptmp" +#define _PATH_SHADOW_PASSWD "/etc/shadow" +#define _PATH_SHADOW_PTMP "/etc/sptmp" +#define _PATH_SHADOW_PTMPTMP "/etc/sptmptmp" +#define _PATH_SHADOW_GROUP "/etc/gshadow" +#define _PATH_SHADOW_GTMP "/etc/sgtmp" +#define _PATH_SHADOW_GTMPTMP "/etc/sgtmptmp" /* used in misc-utils/look.c */ #define _PATH_WORDS "/usr/dict/words" diff --git a/lib/widechar.h b/lib/widechar.h index c440006f7..1aa91f3f4 100644 --- a/lib/widechar.h +++ b/lib/widechar.h @@ -12,6 +12,14 @@ # include #endif +#if 1 +/* explicit prototypes, since sometimes does not give them */ +extern int wcwidth (wint_t c); +extern int wcswidth (const wchar_t *s, size_t n); +extern size_t wcslen (const wchar_t *s); +extern wchar_t *wcsdup (const wchar_t *s); +#endif + #else # include diff --git a/lib/xstrncpy.c b/lib/xstrncpy.c new file mode 100644 index 000000000..cf4940971 --- /dev/null +++ b/lib/xstrncpy.c @@ -0,0 +1,9 @@ +/* NUL-terminated version of strncpy() */ +#include +#include "xstrncpy.h" + +void +xstrncpy(char *dest, const char *src, size_t n) { + strncpy(dest, src, n-1); + dest[n-1] = 0; +} diff --git a/lib/xstrncpy.h b/lib/xstrncpy.h new file mode 100644 index 000000000..05c8fa26f --- /dev/null +++ b/lib/xstrncpy.h @@ -0,0 +1 @@ +extern void xstrncpy(char *dest, const char *src, size_t n); diff --git a/login-utils/Makefile b/login-utils/Makefile index d986501e1..e6b37b8a1 100644 --- a/login-utils/Makefile +++ b/login-utils/Makefile @@ -96,17 +96,17 @@ shutdown.o simpleinit.o: $(LIB)/linux_reboot.h wall.o: ttymsg.h $(LIB)/carefulputc.h agetty: agetty.o -chfn: chfn.o islocal.o setpwnam.o $(LIB)/env.o +chfn: chfn.o islocal.o setpwnam.o $(LIB)/env.o $(LIB)/xstrncpy.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) chsh: chsh.o islocal.o setpwnam.o $(LIB)/env.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) last: last.o ifeq "$(HAVE_PAM)" "yes" -login: login.o $(LIB)/setproctitle.o +login: login.o $(LIB)/setproctitle.o $(LIB)/xstrncpy.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) else -login: login.o $(LIB)/setproctitle.o checktty.o +login: login.o $(LIB)/xstrncpy.o $(LIB)/setproctitle.o checktty.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) endif @@ -115,20 +115,20 @@ mesg: mesg.o $(ERR_O) newgrp: newgrp.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) -shutdown: shutdown.o $(LIB)/my_reboot.o +shutdown: shutdown.o $(LIB)/my_reboot.o $(LIB)/xstrncpy.o -simpleinit: simpleinit.o $(LIB)/my_reboot.o +simpleinit: simpleinit.o $(LIB)/my_reboot.o $(LIB)/xstrncpy.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) initctl: initctl.o $(CC) $(LDFLAGS) -o $@ $^ -vipw: vipw.o +vipw: vipw.o $(LIB)/xstrncpy.o newgrp.o: $(LIB)/pathnames.h $(CC) -c $(CFLAGS) $(PAMFL) newgrp.c -wall: wall.o ttymsg.o $(LIB)/carefulputc.o +wall: wall.o ttymsg.o $(LIB)/carefulputc.o $(LIB)/xstrncpy.o LOGINFLAGS= ifeq "$(USE_TTY_GROUP)" "yes" @@ -145,7 +145,7 @@ login.o: login.c $(LIB)/pathnames.h $(LIB)/setproctitle.c $(LIB)/setproctitle.h mesg.o: mesg.c $(LIB)/errs.h $(CC) -c $(CFLAGS) $(LOGINFLAGS) mesg.c -passwd: passwd.o islocal.o setpwnam.o $(LIB)/env.o +passwd: passwd.o islocal.o setpwnam.o $(LIB)/env.o $(LIB)/xstrncpy.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) ifeq "$(REQUIRE_PASSWORD)" "yes" @@ -214,8 +214,8 @@ ifeq "$(USE_TTY_GROUP)" "yes" chmod g+s $(USRBINDIR)/wall endif -.PHONY: clean -clean: +.PHONY: clean distclean +clean distclean: -rm -f *.o *~ core $(BIN.PASSWD) $(SBIN.GETTY) $(SBIN.INIT) \ $(USRBIN.MISC) $(USRBIN.PASSWD) $(USRBIN.PUTILS) \ $(USRSBIN.PUTILS) $(BIN.PUTILS) diff --git a/login-utils/agetty.c b/login-utils/agetty.c index 63f4adfa6..3a30b16ba 100644 --- a/login-utils/agetty.c +++ b/login-utils/agetty.c @@ -5,7 +5,7 @@ -f option added by Eric Rasmussen - 12/28/95 - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support 1999-05-05 Thorsten Kranzkowski @@ -564,7 +564,6 @@ update_utmp(line) * entry in the utmp file. */ -#ifdef __linux__ utmpname(_PATH_UTMP); setutent(); while ((utp = getutent()) @@ -578,7 +577,6 @@ update_utmp(line) memset(&ut, 0, sizeof(ut)); strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id)); } - /*endutent();*/ strncpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user)); strncpy(ut.ut_line, line, sizeof(ut.ut_line)); @@ -593,7 +591,7 @@ update_utmp(line) endutent(); { -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) +#ifdef HAVE_updwtmp updwtmp(_PATH_WTMP, &ut); #else int ut_fd; @@ -610,31 +608,6 @@ update_utmp(line) } #endif } -#else /* not __linux__ */ - { int ut_fd; - if ((ut_fd = open(UTMP_FILE, 2)) < 0) { - error(_("%s: open for update: %m"), UTMP_FILE); - } else { - long ut_size = sizeof(ut); /* avoid nonsense */ - - while (read(ut_fd, (char *) &ut, sizeof(ut)) == sizeof(ut)) { - if (ut.ut_type == INIT_PROCESS && ut.ut_pid == mypid) { - ut.ut_type = LOGIN_PROCESS; - ut.ut_time = time((long *) 0); - (void) strncpy(ut.ut_name, "LOGIN", sizeof(ut.ut_name)); - (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - if (fakehost) - (void) strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host)); - (void) lseek(ut_fd, -ut_size, 1); - (void) write(ut_fd, (char *) &ut, sizeof(ut)); - (void) close(ut_fd); - return; - } - } - error(_("%s: no utmp entry"), line); - } - } -#endif /* __linux__ */ } #endif diff --git a/login-utils/checktty.c b/login-utils/checktty.c index 6269b6b07..e96647ea6 100644 --- a/login-utils/checktty.c +++ b/login-utils/checktty.c @@ -2,7 +2,7 @@ Created 25-Aug-95 by Peter Orbaek Fixed by JDS June 1996 to clear lists and close files - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support */ @@ -30,6 +30,7 @@ #include "pathnames.h" #include "login.h" +#include "xstrncpy.h" #ifdef TESTING struct hostent hostaddress; @@ -107,8 +108,7 @@ new_class(char *class) tc->next = ttyclasses; tc->first = NULL; - strncpy(tc->classname, class, CLASSNAMELEN); - tc->classname[CLASSNAMELEN-1] = 0; + xstrncpy(tc->classname, class, CLASSNAMELEN); ttyclasses = tc; return tc; } @@ -128,8 +128,7 @@ add_to_class(struct ttyclass *tc, char *tty) } ge->next = tc->first; - strncpy(ge->name, tty, NAMELEN); - ge->name[NAMELEN-1] = 0; + xstrncpy(ge->name, tty, NAMELEN); tc->first = ge; } @@ -267,8 +266,7 @@ in_class(const char *tty, char *class) if (class[0] == '[') { if ((p = strchr(class, ']'))) { *p = 0; - strncpy(timespec, class+1, sizeof(timespec)); - timespec[sizeof(timespec)-1] = 0; + xstrncpy(timespec, class+1, sizeof(timespec)); *p = ']'; if(!timeok(tm, timespec)) return 0; class = p+1; @@ -289,8 +287,7 @@ in_class(const char *tty, char *class) if (n[0] == '[') { if ((p = strchr(n, ']'))) { *p = 0; - strncpy(timespec, n+1, sizeof(timespec)); - timespec[sizeof(timespec)-1] = 0; + xstrncpy(timespec, n+1, sizeof(timespec)); *p = ']'; if(!timeok(tm, timespec)) continue; n = p+1; @@ -373,8 +370,7 @@ checktty(const char *user, const char *tty, struct passwd *pwd) if(*ptr == '#') *ptr = 0; if (buf[0] == '*') { - strncpy(defaultbuf, buf, 256); - defaultbuf[255] = 0; + xstrncpy(defaultbuf, buf, 256); continue; } diff --git a/login-utils/chfn.c b/login-utils/chfn.c index de228241b..e25212e88 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -16,7 +16,7 @@ * Hacked by Peter Breitenlohner, peb@mppmu.mpg.de, * to remove trailing empty fields. Oct 5, 96. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * @@ -36,6 +36,7 @@ #include "my_crypt.h" #include "islocal.h" #include "setpwnam.h" +#include "xstrncpy.h" #include "nls.h" #include "env.h" @@ -239,8 +240,7 @@ static boolean parse_argv (argc, argv, pinfo) info_given = true; status = 0; - strncpy (buf, whoami, sizeof(buf)-128); - buf[sizeof(buf)-128-1] = 0; + xstrncpy (buf, whoami, sizeof(buf)-128); strcat (buf, ": "); /* now store the argument */ diff --git a/login-utils/chsh.c b/login-utils/chsh.c index d1a3fa820..fd9b5899e 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -17,7 +17,7 @@ * suggestion from Zefram. Disallowing users with shells not in /etc/shells * from changing their shell. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * diff --git a/login-utils/cryptocard.c b/login-utils/cryptocard.c index 9e221cbe6..44cfb55d5 100644 --- a/login-utils/cryptocard.c +++ b/login-utils/cryptocard.c @@ -17,7 +17,7 @@ ftp://ftp.daimi.aau.dk/pub/linux/poe/poeigl-X.XX.tar.gz - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support */ diff --git a/login-utils/islocal.c b/login-utils/islocal.c index 87f8f1cb2..1ee84089f 100644 --- a/login-utils/islocal.c +++ b/login-utils/islocal.c @@ -10,7 +10,7 @@ to distinguish user names where one is a prefix of the other, and to use "pathnames.h". Oct 5, 96. - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support diff --git a/login-utils/last.c b/login-utils/last.c index 8375f9f07..8d3a8911a 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -18,10 +18,14 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* 1999-02-22 Arkadiusz Mi¶kiewicz + /* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ + /* 2001-02-14 Marek Zelem + * - using mmap() on Linux - great speed improvement + */ + /* * last */ @@ -29,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -197,8 +202,15 @@ wtmp(void) { long delta; /* time difference */ char *crmsg = NULL; char *ct = NULL; +#if USE_GETUTENT struct utmp **utmplist = NULL; int listlen = 0; +#else + int fd; + struct utmp *utl; + struct stat st; + int utl_len; +#endif int listnr = 0; int i; @@ -208,6 +220,7 @@ wtmp(void) { (void)signal(SIGINT, onintr); (void)signal(SIGQUIT, onintr); +#if USE_GETUTENT setutent(); while((bp = getutent())) { if(listnr >= listlen) { @@ -220,12 +233,31 @@ wtmp(void) { memcpy(utmplist[listnr++], bp, sizeof(*bp)); } endutent(); +#else + if ((fd = open(file,O_RDONLY)) < 0) + exit(1); + fstat(fd, &st); + utl_len = st.st_size; + utl = mmap(NULL, utl_len, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_FILE, fd, 0); + if (utl == NULL) + exit(1); + listnr = utl_len/sizeof(struct utmp); +#endif if(listnr) +#if USE_GETUTENT ct = ctime(&utmplist[0]->ut_time); +#else + ct = ctime(&utl[0].ut_time); +#endif for(i = listnr - 1; i >= 0; i--) { +#if USE_GETUTENT bp = utmplist[i]; +#else + bp = utl+i; +#endif /* * if the terminal line is '~', the machine stopped. * see utmp(5) for more info. @@ -245,7 +277,8 @@ wtmp(void) { } currentout = -bp->ut_time; - crmsg = strncmp(bp->ut_name, "shutdown", NMAX) ? "crash" : "down "; + crmsg = (strncmp(bp->ut_name, "shutdown", NMAX) + ? "crash" : "down "); if (!bp->ut_name[0]) (void)strcpy(bp->ut_name, "reboot"); if (want(bp, NO)) { @@ -295,9 +328,15 @@ wtmp(void) { } T->logout = bp->ut_time; utmpbuf.ut_time = bp->ut_time; +#if USE_GETUTENT free(bp); } if(utmplist) free(utmplist); +#else + } + munmap(utl,utl_len); + close(fd); +#endif if(ct) printf(_("\nwtmp begins %s"), ct); /* ct already ends in \n */ } diff --git a/login-utils/login.c b/login-utils/login.c index 3ad3b219c..1cf188fba 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -52,7 +52,7 @@ From 1992 till now (1997) this code for Linux has been maintained at ftp.daimi.aau.dk:/pub/linux/poe/ - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support Sun Mar 21 1999 - Arnaldo Carvalho de Melo - fixed strerr(errno) in gettext calls @@ -119,6 +119,7 @@ #include "pathnames.h" #include "my_crypt.h" #include "login.h" +#include "xstrncpy.h" #include "nls.h" #ifdef __linux__ @@ -145,8 +146,11 @@ syslog(LOG_ERR,"%s",pam_strerror(pamh, retcode)); \ pam_end(pamh, retcode); exit(1); \ } -# define PAM_END { retcode = pam_close_session(pamh,0); \ - pam_end(pamh,retcode); } +# define PAM_END { \ + pam_setcred(pamh, PAM_DELETE_CRED); \ + retcode = pam_close_session(pamh,0); \ + pam_end(pamh,retcode); \ +} #endif #ifndef __linux__ @@ -190,13 +194,14 @@ struct lastlog }; #endif - +#ifndef USE_PAM static void getloginname (void); +static void checknologin (void); +static int rootterm (char *ttyn); +#endif static void timedout (int); static void sigint (int); -static int rootterm (char *ttyn); static void motd (void); -static void checknologin (void); static void dolastlog (int quiet); #ifndef __linux__ @@ -355,8 +360,7 @@ main(int argc, char **argv) * host to login so that it may be placed in utmp and wtmp */ gethostname(tbuf, sizeof(tbuf)); - strncpy(thishost, tbuf, sizeof(thishost)-1); - thishost[sizeof(thishost)-1] = 0; + xstrncpy(thishost, tbuf, sizeof(thishost)); domain = index(tbuf, '.'); username = tty = hostname = NULL; @@ -590,14 +594,21 @@ main(int argc, char **argv) First get the username that we are actually using, though. */ retcode = pam_get_item(pamh, PAM_USER, (const void **) &username); - setpwent(); - pwd = getpwnam(username); + if (retcode == PAM_SUCCESS && username && *username) { + pwd = getpwnam(username); + } + + /* + * Initialize the supplementary group list. + * This should be done before pam_setcred because + * the PAM modules might add groups during pam_setcred. + */ if (pwd) initgroups(username, pwd->pw_gid); - retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED); + retcode = pam_open_session(pamh, 0); PAM_FAIL_CHECK; - retcode = pam_open_session(pamh, 0); + retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED); PAM_FAIL_CHECK; #else /* ! USE_PAM */ @@ -795,66 +806,6 @@ main(int argc, char **argv) } } -#ifndef __linux__ -# ifdef KERBEROS - if (notickets && !quietlog) - printf(_("Warning: no Kerberos tickets issued\n")); -# endif - -# ifndef USE_PAM /* PAM does all of this for us */ -# define TWOWEEKS (14*24*60*60) - if (pwd->pw_change || pwd->pw_expire) { - struct timeval tp; - - gettimeofday(&tp, (struct timezone *)NULL); - - if (pwd->pw_change) { - if (tp.tv_sec >= pwd->pw_change) { - printf(_("Sorry -- your password has expired.\n")); - sleepexit(1); - } - else if (tp.tv_sec - pwd->pw_change < TWOWEEKS && !quietlog) { - struct tm *ttp; - ttp = localtime(&pwd->pw_change); - printf(_("Warning: your password expires on %d %s %d.\n"), - ttp->tm_mday, months[ttp->tm_mon], - TM_YEAR_BASE + ttp->tm_year); - } - } - - if (pwd->pw_expire) { - if (tp.tv_sec >= pwd->pw_expire) { - printf(_("Sorry -- your account has expired.\n")); - sleepexit(1); - } - else if (tp.tv_sec - pwd->pw_expire < TWOWEEKS && !quietlog) { - struct tm *ttp; - ttp = localtime(&pwd->pw_expire); - printf(_("Warning: your account expires on %d %s %d.\n"), - ttp->tm_mday, months[ttp->tm_mon], - TM_YEAR_BASE + ttp->tm_year); - } - } - } -# endif /* !USE_PAM */ - - /* nothing else left to fail -- really log in */ - { - struct utmp utmp; - - memset((char *)&utmp, 0, sizeof(utmp)); - time(&utmp.ut_time); - strncpy(utmp.ut_name, username, sizeof(utmp.ut_name)); - /* ut_name may legally be non-null-terminated */ - if (hostname) { - strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host)); - utmp.ut_host[sizeof(utmp.ut_host)-1] = 0; - } - strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line)); - utmp.ut_line[sizeof(utmp.ut_line)-1] = 0; - login(&utmp); - } -#else /* __linux__ defined */ /* for linux, write entries in utmp and wtmp */ { struct utmp ut; @@ -898,8 +849,7 @@ Michael Riepe strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id)); strncpy(ut.ut_user, username, sizeof(ut.ut_user)); - strncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line)); - ut.ut_line[sizeof(ut.ut_line)-1] = 0; + xstrncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line)); #ifdef _HAVE_UT_TV /* in included by */ gettimeofday(&ut.ut_tv, NULL); #else @@ -913,8 +863,7 @@ Michael Riepe ut.ut_type = USER_PROCESS; ut.ut_pid = mypid; if (hostname) { - strncpy(ut.ut_host, hostname, sizeof(ut.ut_host)); - ut.ut_host[sizeof(ut.ut_host)-1] = 0; + xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host)); if (hostaddress.h_addr_list) memcpy(&ut.ut_addr, hostaddress.h_addr_list[0], sizeof(ut.ut_addr)); @@ -923,7 +872,7 @@ Michael Riepe pututline(&ut); endutent(); -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) +#ifdef HAVE_updwtmp updwtmp(_PATH_WTMP, &ut); #else #if 0 @@ -953,19 +902,11 @@ Michael Riepe } } #endif -#endif /* __GLIBC__ */ +#endif } -#endif /* __linux__ */ dolastlog(quietlog); -#ifndef __linux__ - if (!hflag) { /* XXX */ - static struct winsize win = { 0, 0, 0, 0 }; - - ioctl(0, TIOCSWINSZ, &win); - } -#endif chown(ttyn, pwd->pw_uid, (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid); chmod(ttyn, TTY_MODE); @@ -1012,17 +953,6 @@ Michael Riepe memset(environ, 0, sizeof(char*)); } -#ifndef __linux__ - setenv("HOME", pwd->pw_dir, 1); - setenv("SHELL", pwd->pw_shell, 1); - if (term[0] == '\0') { - strncpy(term, stypeof(tty), sizeof(term)); - term[sizeof(term)-1] = 0; - } - setenv("TERM", term, 0); - setenv("USER", pwd->pw_name, 1); - setenv("PATH", _PATH_DEFPATH, 0); -#else setenv("HOME", pwd->pw_dir, 0); /* legal to override */ if(pwd->pw_uid) setenv("PATH", _PATH_DEFPATH, 1); @@ -1046,7 +976,6 @@ Michael Riepe HP-UX 6.5 does it. We'll not allow modifying it. */ setenv("LOGNAME", pwd->pw_name, 1); -#endif #ifdef USE_PAM { @@ -1108,9 +1037,16 @@ Michael Riepe signal(SIGHUP, SIG_DFL); #ifdef USE_PAM - /* We must fork before setuid() because we need to call + /* + * We must fork before setuid() because we need to call * pam_close_session() as root. */ + /* + * Problem: if the user's shell is a shell like ash that doesnt do + * setsid() or setpgrp(), then a ctrl-\, sending SIGQUIT to every + * process in the pgrp, will kill us. + * Solution: use TIOCNOTTY and setsid(). + */ signal(SIGINT, SIG_IGN); childPid = fork(); if (childPid < 0) { @@ -1121,11 +1057,16 @@ Michael Riepe exit(0); } else if (childPid) { /* parent - wait for child to finish, then cleanup session */ + signal(SIGHUP, SIG_IGN); /* ignore signal from TIOCNOTTY */ + ioctl(0, TIOCNOTTY, NULL); + signal(SIGHUP, SIG_DFL); + wait(NULL); PAM_END; exit(0); } /* child */ + setsid(); #endif signal(SIGINT, SIG_DFL); @@ -1161,10 +1102,9 @@ Michael Riepe childArgv[childArgc++] = buff; } else { tbuf[0] = '-'; - strncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ? + xstrncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ? p + 1 : pwd->pw_shell), sizeof(tbuf)-1); - tbuf[sizeof(tbuf)-1] = 0; childArgv[childArgc++] = pwd->pw_shell; childArgv[childArgc++] = tbuf; @@ -1185,7 +1125,8 @@ Michael Riepe exit(0); } -void +#ifndef USE_PAM +static void getloginname(void) { int ch, cnt, cnt2; char *p; @@ -1229,6 +1170,7 @@ getloginname(void) { } } } +#endif void timedout(int sig) { @@ -1243,6 +1185,7 @@ timedout(int sig) { exit(0); } +#ifndef USE_PAM int rootterm(char * ttyn) #ifndef __linux__ @@ -1279,7 +1222,8 @@ rootterm(char * ttyn) } } } -#endif +#endif /* !__linux__ */ +#endif /* !USE_PAM */ jmp_buf motdinterrupt; @@ -1342,12 +1286,10 @@ dolastlog(int quiet) { } memset((char *)&ll, 0, sizeof(ll)); time(&ll.ll_time); - strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); - ll.ll_line[sizeof(ll.ll_line)-1] = 0; - if (hostname) { - strncpy(ll.ll_host, hostname, sizeof(ll.ll_host)); - ll.ll_host[sizeof(ll.ll_host)-1] = 0; - } + xstrncpy(ll.ll_line, tty, sizeof(ll.ll_line)); + if (hostname) + xstrncpy(ll.ll_host, hostname, sizeof(ll.ll_host)); + write(fd, (char *)&ll, sizeof(ll)); close(fd); } diff --git a/login-utils/mesg.c b/login-utils/mesg.c index bfa17eb11..2b08d8350 100644 --- a/login-utils/mesg.c +++ b/login-utils/mesg.c @@ -39,7 +39,7 @@ * Modified Mon Jul 1 18:14:10 1996, janl@ifi.uio.no, writing to stdout * as suggested by Michael Meskes * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index ade173e53..89db17548 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -3,7 +3,7 @@ /* Vesa Roukonen added code for asking password */ /* Currently maintained at ftp://ftp.daimi.aau.dk/pub/linux/poe/ */ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ diff --git a/login-utils/passwd.c b/login-utils/passwd.c index 6741ee210..d931d3b88 100644 --- a/login-utils/passwd.c +++ b/login-utils/passwd.c @@ -38,7 +38,7 @@ * auth.warning. (Of course, the password itself is not logged.) */ - /* 1999-02-22 Arkadiusz Mi¶kiewicz + /* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * Sun Mar 21 1999 - Arnaldo Carvalho de Melo * - fixed strerr(errno) in gettext calls @@ -68,6 +68,7 @@ #include "my_crypt.h" #include "setpwnam.h" #include "islocal.h" +#include "xstrncpy.h" #include "nls.h" #include "env.h" @@ -375,8 +376,7 @@ main(int argc, char *argv[]) { && !check_passwd(pwdstr, pe->pw_passwd, user, pe->pw_gecos) ) goto redo_it; - strncpy(pwdstr1, pwdstr, 9); - pwdstr1[9] = 0; + xstrncpy(pwdstr1, pwdstr, sizeof(pwdstr1)); pwdstr = getpass(_("Re-type new password: ")); if(strncmp(pwdstr, pwdstr1, 8)) { diff --git a/login-utils/setpwnam.h b/login-utils/setpwnam.h index 84d1c208f..e7f44a94c 100644 --- a/login-utils/setpwnam.h +++ b/login-utils/setpwnam.h @@ -22,6 +22,15 @@ #define GROUP_FILE _PATH_GROUP #define GTMP_FILE _PATH_GTMP #define GTMPTMP_FILE _PATH_GTMPTMP + +#define SHADOW_FILE _PATH_SHADOW_PASSWD +#define SPTMP_FILE _PATH_SHADOW_PTMP +#define SPTMPTMP_FILE _PATH_SHADOW_PTMPTMP + +#define SGROUP_FILE _PATH_SHADOW_GROUP +#define SGTMP_FILE _PATH_SHADOW_GTMP +#define SGTMPTMP_FILE _PATH_SHADOW_GTMPTMP + #else #define PASSWD_FILE "/tmp/passwd" #define PTMP_FILE "/tmp/ptmp" @@ -30,6 +39,14 @@ #define GROUP_FILE "/tmp/group" #define GTMP_FILE "/tmp/gtmp" #define GTMPTMP_FILE "/tmp/gtmptmp" + +#define SHADOW_FILE "/tmp/shadow" +#define SPTMP_FILE "/tmp/sptmp" +#define SPTMPTMP_FILE "/tmp/sptmptmp" + +#define SGROUP_FILE "/tmp/gshadow" +#define SGTMP_FILE "/tmp/sgtmp" +#define SGTMPTMP_FILE "/tmp/sgtmptmp" #endif extern int setpwnam (struct passwd *pwd); diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c index d1034d5eb..036064aad 100644 --- a/login-utils/shutdown.c +++ b/login-utils/shutdown.c @@ -28,7 +28,7 @@ * Changes by Richard Gooch (butchered by aeb) * introducing shutdown.conf. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * 2000-03-02 Richard Gooch @@ -71,6 +71,7 @@ #include #include "linux_reboot.h" #include "pathnames.h" +#include "xstrncpy.h" #include "nls.h" static void usage(void), int_handler(int), write_user(struct utmp *); @@ -249,8 +250,7 @@ main(int argc, char *argv[]) exit(1); } } else { - strncpy(message, argv[c], sizeof(message)); - message[sizeof(message)-1] = '\0'; + xstrncpy(message, argv[c], sizeof(message)); opt_msgset = 1; } } diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c index 9c4b63a5f..56f10455a 100644 --- a/login-utils/simpleinit.c +++ b/login-utils/simpleinit.c @@ -1,8 +1,14 @@ /* simpleinit.c - poe@daimi.aau.dk */ -/* Version 1.21 */ +/* Version 2.0.1 */ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support + * 2001-01-25 Richard Gooch + * - fixed bug with failed services so they may be later "reclaimed" + * 2001-02-02 Richard Gooch + * - fixed race when reading from pipe and reaping children + * 2001-02-18 sam@quux.dropbear.id.au + * - fixed bug in : multiple INIT_PATH components did not work */ #include @@ -31,6 +37,7 @@ #include "my_crypt.h" #include "pathnames.h" #include "linux_reboot.h" +#include "xstrncpy.h" #include "nls.h" #include "simpleinit.h" @@ -77,7 +84,8 @@ static sigjmp_buf jmp_env; static void do_single (void); static int do_rc_tty (const char *path); -static int process_path ( const char *path, int (*func) (const char *path) ); +static int process_path (const char *path, int (*func) (const char *path), + int ignore_dangling_symlink); static int preload_file (const char *path); static int run_file (const char *path); static void spawn (int i), read_inittab (void); @@ -91,7 +99,7 @@ static void sigterm_handler (int sig); static void set_tz (void); #endif static void write_wtmp (void); -static pid_t mywaitpid (pid_t pid, int *status); +static pid_t mywait (int *status); static int run_command (const char *file, const char *name, pid_t pid); @@ -221,7 +229,7 @@ int main(int argc, char *argv[]) } for ever { - pid = mywaitpid (-1, &vec); + pid = mywait (&vec); if (pid < 1) continue; /* clear utmp entry, and append to wtmp if possible */ @@ -322,7 +330,7 @@ static int do_rc_tty (const char *path) sigset_t ss; if (caught_sigint) return 0; - process_path (path, preload_file); + process_path (path, preload_file, 0); /* Launch off a subprocess to start a new session (required for frobbing the TTY) and capture control-C */ switch ( child = fork () ) @@ -344,10 +352,10 @@ static int do_rc_tty (const char *path) break; } /* Parent */ - process_path (path, run_file); + process_path (path, run_file, 0); while (1) { - if ( ( pid = mywaitpid (-1, &status) ) == child ) + if ( ( pid = mywait (&status) ) == child ) return (WTERMSIG (status) == SIGINT) ? 0 : 1; if (pid < 0) break; } @@ -356,17 +364,27 @@ static int do_rc_tty (const char *path) return 0; } /* End Function do_rc_tty */ -static int process_path ( const char *path, int (*func) (const char *path) ) +static int process_path (const char *path, int (*func) (const char *path), + int ignore_dangling_symlink) { struct stat statbuf; DIR *dp; struct dirent *de; - if (stat (path, &statbuf) != 0) + if (lstat (path, &statbuf) != 0) { - err (_ ("stat of path failed\n") ); + err (_ ("lstat of path failed\n") ); return 1; } + if ( S_ISLNK (statbuf.st_mode) ) + { + if (stat (path, &statbuf) != 0) + { + if ( (errno == ENOENT) && ignore_dangling_symlink ) return 0; + err (_ ("stat of path failed\n") ); + return 1; + } + } if ( !( statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH) ) ) return 0; if ( !S_ISDIR (statbuf.st_mode) ) return (*func) (path); if ( ( dp = opendir (path) ) == NULL ) @@ -382,7 +400,7 @@ static int process_path ( const char *path, int (*func) (const char *path) ) if (de->d_name[0] == '.') continue; retval = sprintf (newpath, "%s/%s", path, de->d_name); if (newpath[retval - 1] == '~') continue; /* Common mistake */ - if ( ( retval = process_path (newpath, func) ) ) return retval; + if ( ( retval = process_path (newpath, func, 1) ) ) return retval; } closedir (dp); return 0; @@ -545,11 +563,8 @@ static void read_inittab (void) (void) strcpy(inittab[i].line, buf); (void) strtok(inittab[i].line, ":"); - (void) strncpy(inittab[i].tty, inittab[i].line, 10); - inittab[i].tty[9] = 0; - (void) strncpy(inittab[i].termcap, - strtok((char *)0, ":"), 30); - inittab[i].termcap[29] = 0; + xstrncpy(inittab[i].tty, inittab[i].line, 10); + xstrncpy(inittab[i].termcap, strtok((char *)0, ":"), 30); getty = strtok((char *)0, ":"); (void) strtok(getty, " \t\n"); @@ -566,10 +581,8 @@ static void read_inittab (void) err(_("no TERM or cannot stat tty\n")); } else { /* is it a console tty? */ - if(major(stb.st_rdev) == 4 && minor(stb.st_rdev) < 64) { - strncpy(inittab[i].termcap, termenv, 30); - inittab[i].termcap[29] = 0; - } + if(major(stb.st_rdev) == 4 && minor(stb.st_rdev) < 64) + xstrncpy(inittab[i].termcap, termenv, 30); } #endif @@ -752,40 +765,40 @@ static void show_scripts (FILE *fp, const struct script_struct *script, static const char *get_path (const char *file); -static pid_t mywaitpid (pid_t pid, int *status) +static pid_t mywait (int *status) /* [RETURNS] The pid for a process to be reaped, 0 if no process is to be reaped, and less than 0 if the boot scripts appear to have finished. */ { - int ival; - sigset_t ss_new, ss_old; + pid_t pid; + sigset_t ss; long buffer[COMMAND_SIZE / sizeof (long)]; struct command_struct *command = (struct command_struct *) buffer; - if (initctl_fd < 0) return waitpid (pid, status, 0); - if (status == NULL) status = &ival; - if ( ( pid = waitpid (pid, status, WNOHANG) ) > 0 ) - { - return process_pidstat (pid, *status); - } - /* Some magic to avoid races */ + if (initctl_fd < 0) return wait (status); + /* Some magic to avoid races which can result in lost signals */ command->command = -1; - sigemptyset (&ss_new); - sigaddset (&ss_new, SIGCHLD); - sigprocmask (SIG_BLOCK, &ss_new, &ss_old); - ival = sigsetjmp (jmp_env, 0); - sigprocmask (SIG_SETMASK, &ss_old, NULL); - if (ival == 0) do_longjmp = 1; - else - { + if ( sigsetjmp (jmp_env, 1) ) + { /* Jump from signal handler */ do_longjmp = 0; - if (command->command < 0) return 0; + process_command (command); + return 0; + } + sigemptyset (&ss); /* Block SIGCHLD so wait status cannot be lost */ + sigaddset (&ss, SIGCHLD); + sigprocmask (SIG_BLOCK, &ss, NULL); + if ( ( pid = waitpid (-1, status, WNOHANG) ) > 0 ) + { + sigprocmask (SIG_UNBLOCK, &ss, NULL); + return process_pidstat (pid, *status); } - if (command->command < 0) read (initctl_fd, buffer, COMMAND_SIZE); + do_longjmp = 1; /* After this, SIGCHLD will cause a jump backwards */ + sigprocmask (SIG_UNBLOCK, &ss, NULL); + read (initctl_fd, buffer, COMMAND_SIZE); do_longjmp = 0; process_command (command); return 0; -} /* End Function mywaitpid */ +} /* End Function mywait */ static pid_t process_pidstat (pid_t pid, int status) /* [RETURNS] The pid for a process to be reaped, 0 if no process is to be @@ -978,7 +991,7 @@ static int run_command (const char *file, const char *name, pid_t pid) script = find_script_byname (name, &starting_list, &service); if (script == NULL) service = find_service_in_list (name, unavailable_services); - if (script == NULL) + if (service == NULL) { int i; char txt[1024]; @@ -988,24 +1001,13 @@ static int run_command (const char *file, const char *name, pid_t pid) if (needer != NULL) free (needer); return SIG_FAILED; } + service = calloc (1, strlen (name) + sizeof *service); if (service == NULL) { - service = calloc (1, strlen (name) + sizeof *service); - if (service == NULL) - { - free (script); - return SIG_FAILED; - } - strcpy (service->name, name); - } - else /* Unhook service from unavailable list */ - { - if (service->prev == NULL) unavailable_services = service->next; - else service->prev->next = service->next; - if (service->next != NULL) service->next->prev = service->prev; - service->prev = NULL; - service->next = NULL; + free (script); + return SIG_FAILED; } + strcpy (service->name, name); switch ( script->pid = fork () ) { case 0: /* Child */ @@ -1063,6 +1065,7 @@ static struct script_struct *find_script_byname (const char *name, return (script); } } + if (service != NULL) *service = NULL; return NULL; } /* End Function find_script_byname */ @@ -1121,6 +1124,7 @@ static void handle_nonworking (struct script_struct *script) next = service->next; if (provider == NULL) { + service->prev = NULL; service->next = unavailable_services; if (unavailable_services != NULL) unavailable_services->prev = service; @@ -1180,7 +1184,7 @@ static const char *get_path (const char *file) p2 = p1 + strlen (p1); strncpy (path, p1, p2 - p1); path[p2 - p1] = '/'; - strcat (path + (p2 - p1) + 1, file); + strcpy (path + (p2 - p1) + 1, file); if (*p2 == ':') ++p2; if (access (path, X_OK) == 0) return path; } diff --git a/login-utils/ttymsg.c b/login-utils/ttymsg.c index b422abb85..55b26a82a 100644 --- a/login-utils/ttymsg.c +++ b/login-utils/ttymsg.c @@ -34,7 +34,7 @@ * */ - /* 1999-02-22 Arkadiusz Mi¶kiewicz + /* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * Sun Mar 21 1999 - Arnaldo Carvalho de Melo * - fixed strerr(errno) in gettext calls diff --git a/login-utils/vipw.c b/login-utils/vipw.c index 665d77daa..f6133ac98 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -38,7 +38,7 @@ * * Martin Schulze's patches adapted to Util-Linux by Nicolai Langfeldt. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * Sun Mar 21 1999 - Arnaldo Carvalho de Melo * - fixed strerr(errno) in gettext calls @@ -64,6 +64,7 @@ static char version_string[] = "vipw 1.4"; #include #include "setpwnam.h" +#include "xstrncpy.h" #include "nls.h" #define FILENAMELEN 67 @@ -132,13 +133,6 @@ pw_lock(void) { * that users can't get at the encrypted passwords while editing. * Open should allow flock'ing the file; see 4.4BSD. XXX */ - lockfd = open(orig_file, O_RDONLY, 0); - - if (lockfd < 0) { - (void)fprintf(stderr, "%s: %s: %s\n", - progname, orig_file, strerror(errno)); - exit(1); - } #if 0 /* flock()ing is superfluous here, with the ptmp/ptmptmp system. */ if (flock(lockfd, LOCK_EX|LOCK_NB)) { (void)fprintf(stderr, @@ -169,6 +163,16 @@ pw_lock(void) { } exit(1); } + + lockfd = open(orig_file, O_RDONLY, 0); + + if (lockfd < 0) { + (void)fprintf(stderr, "%s: %s: %s\n", + progname, orig_file, strerror(errno)); + unlink(tmp_file); + exit(1); + } + copyfile(lockfd, fd); (void)close(lockfd); (void)close(fd); @@ -253,9 +257,28 @@ pw_error(name, err, eval) exit(eval); } +static void +edit_file(void) +{ + struct stat begin, end; + + pw_init(); + pw_lock(); + + if (stat(tmp_file, &begin)) + pw_error(tmp_file, 1, 1); + pw_edit(0); + if (stat(tmp_file, &end)) + pw_error(tmp_file, 1, 1); + if (begin.st_mtime == end.st_mtime) { + (void)fprintf(stderr, _("%s: no changes made\n"), progname); + pw_error((char *)NULL, 0, 0); + } + pw_unlock(); +} + int main(int argc, char *argv[]) { - struct stat begin, end; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -265,15 +288,14 @@ int main(int argc, char *argv[]) progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0]; if (!strcmp(progname, "vigr")) { program = VIGR; - strncpy(orig_file, GROUP_FILE, FILENAMELEN-1); - strncpy(tmp_file, GTMP_FILE, FILENAMELEN-1); - strncpy(tmptmp_file, GTMPTMP_FILE, FILENAMELEN-1); - } - else { + xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file)); + xstrncpy(tmp_file, GTMP_FILE, sizeof(tmp_file)); + xstrncpy(tmptmp_file, GTMPTMP_FILE, sizeof(tmptmp_file)); + } else { program = VIPW; - strncpy(orig_file, PASSWD_FILE, FILENAMELEN-1); - strncpy(tmp_file, PTMP_FILE, FILENAMELEN-1); - strncpy(tmptmp_file, PTMPTMP_FILE, FILENAMELEN-1); + xstrncpy(orig_file, PASSWD_FILE, sizeof(orig_file)); + xstrncpy(tmp_file, PTMP_FILE, sizeof(tmp_file)); + xstrncpy(tmptmp_file, PTMPTMP_FILE, sizeof(tmptmp_file)); } if ((argc > 1) && @@ -282,18 +304,32 @@ int main(int argc, char *argv[]) exit(0); } - pw_init(); - pw_lock(); - - if (stat(tmp_file, &begin)) - pw_error(tmp_file, 1, 1); - pw_edit(0); - if (stat(tmp_file, &end)) - pw_error(tmp_file, 1, 1); - if (begin.st_mtime == end.st_mtime) { - (void)fprintf(stderr, _("%s: no changes made\n"), progname); - pw_error((char *)NULL, 0, 0); + edit_file(); + + if (program == VIGR) { + strncpy(orig_file, SGROUP_FILE, FILENAMELEN-1); + strncpy(tmp_file, SGTMP_FILE, FILENAMELEN-1); + strncpy(tmptmp_file, SGTMPTMP_FILE, FILENAMELEN-1); + } else { + strncpy(orig_file, SHADOW_FILE, FILENAMELEN-1); + strncpy(tmp_file, SPTMP_FILE, FILENAMELEN-1); + strncpy(tmptmp_file, SPTMPTMP_FILE, FILENAMELEN-1); } - pw_unlock(); + + if (!access(orig_file, X_OK)) { + char response[80]; + + printf((program == VIGR) + ? _("You are using shadow groups on this system.\n") + : _("You are using shadow passwords on this system.\n")); + printf(_("Would you like to edit %s now [y/n]? "), orig_file); + + /* EOF means no */ + if (fgets(response, sizeof(response), stdin)) { + if (response[0] == 'y' || response[0] == 'Y') + edit_file(); + } + } + exit(0); } diff --git a/login-utils/wall.c b/login-utils/wall.c index 6840015d4..3a13fe7ba 100644 --- a/login-utils/wall.c +++ b/login-utils/wall.c @@ -37,7 +37,7 @@ * This program is not related to David Wall, whose Stanford Ph.D. thesis * is entitled "Mechanisms for Broadcast and Selective Broadcast". * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * */ @@ -53,10 +53,12 @@ #include #include #include +#include #include #include #include "nls.h" +#include "xstrncpy.h" #include "ttymsg.h" #include "pathnames.h" #include "carefulputc.h" @@ -115,14 +117,14 @@ usage: iov.iov_len = mbufsize; while((utmpptr = getutent())) { if (!utmpptr->ut_name[0] || - !strncmp(utmpptr->ut_name, IGNOREUSER, sizeof(utmpptr->ut_name))) + !strncmp(utmpptr->ut_name, IGNOREUSER, + sizeof(utmpptr->ut_name))) continue; #ifdef USER_PROCESS if (utmpptr->ut_type != USER_PROCESS) continue; #endif - strncpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line)); - line[sizeof(utmpptr->ut_line)-1] = '\0'; + xstrncpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line)); if ((p = ttymsg(&iov, 1, line, 60*5)) != NULL) (void)fprintf(stderr, "%s: %s\n", progname, p); } diff --git a/misc-utils/Makefile b/misc-utils/Makefile index 5b74dd39e..9fedca66d 100644 --- a/misc-utils/Makefile +++ b/misc-utils/Makefile @@ -21,7 +21,7 @@ BIN= kill USRBIN= cal chkdupexe ddate logger look mcookie \ namei rename script whereis write -MAYBE= reset setterm tsort +MAYBE= reset setterm ifeq "$(HAVE_RESET)" "no" USRBIN:=$(USRBIN) reset @@ -33,11 +33,6 @@ USRBIN:=$(USRBIN) setterm MAN1:=$(MAN1) setterm.1 endif -ifeq "$(HAVE_TSORT)" "no" -USRBIN:=$(USRBIN) tsort -MAN1:=$(MAN1) tsort.1 -endif - # For script only LIBPTY= ifeq "$(HAVE_OPENPTY)" "yes" diff --git a/misc-utils/cal.c b/misc-utils/cal.c index aba1b6f06..768b0a510 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -36,7 +36,7 @@ /* 1999-02-01 Jean-Francois Bignolles: added option '-m' to display * monday as the first day of the week. - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * 2000-09-01 Michael Charles Pruznick diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c index bf7a37f28..c36f9be3d 100644 --- a/misc-utils/ddate.c +++ b/misc-utils/ddate.c @@ -26,7 +26,7 @@ 59 Bcy, 3161: PRAISE_BOB and KILL_BOB options split, other minor changes. - 1999-02-22 Arkadiusz Mi¶kiewicz + 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support 2000-03-17 Burt Holzman diff --git a/misc-utils/flushb.c b/misc-utils/flushb.c new file mode 100644 index 000000000..34ef9cf63 --- /dev/null +++ b/misc-utils/flushb.c @@ -0,0 +1,5 @@ +/* + * Some people submit a utility flushb.c. + * However, it is useless, BLKFLSBUF is already part of blockdev, + * so that "flushb device" is the same as "blockdev --flushbufs device". + */ diff --git a/misc-utils/kill.1 b/misc-utils/kill.1 index f4fd6436d..78fd8bbc6 100644 --- a/misc-utils/kill.1 +++ b/misc-utils/kill.1 @@ -5,64 +5,83 @@ .SH NAME kill \- terminate a process .SH SYNOPSIS -.BR "kill" " [ \-s signal | \-p ] " " [ -a ] " "pid ..." +.BI "kill [ \-s " signal " | \-p ] [ \-a ] [ \-\- ] " "pid ..." .br -.B "kill -l [ signal ]" +.BI "kill -l [ " signal " ]" .SH DESCRIPTION +The command .B kill -sends the specified signal to the specified process. If no signal is -specified, the TERM signal is sent. The TERM signal will kill processes -which do not catch this signal. For other processes, if may be necessary -to use the KILL (9) signal, since this signal cannot be caught. - -Most modern shells have a builtin kill function. +sends the specified signal to the specified process or process group. +If no signal is specified, the TERM signal is sent. The TERM signal +will kill processes which do not catch this signal. For other processes, +it may be necessary to use the KILL (9) signal, since this signal cannot +be caught. +.PP +Most modern shells have a builtin kill function, with a usage rather similar +to that of the command described here. The `-a' and `-p' options, +and the possibility to specify pids by command name is a local extension. .SH OPTIONS .TP -.BR "pid ..." +.IR pid ... Specify the list of processes that .B kill should signal. Each .I pid -can be one of four things. A -.I "process name" -in which case processes called that will be signaled. +can be one of five things: + +.RS +.TP .I n where .I n is larger than 0. The process with pid .I n will be signaled. -.I -1 -in which case all processes from MAX_INT to 2 will be signaled, -as allowed by the issuing user. -.I -n +.TP +.B 0 +All processes in the current process group are signaled. +.TP +.B -1 +All processes with pid larger than 1 will be signaled. +.TP +.BI - n where .I n -is larger than 1, in which case processes in process group +is larger than 1. +All processes in process group .I n -are signaled. IFF a negative argument is given the signal -.I must -be specified first, otherwise it will be taken as the signal to send. +are signaled. When an argument of the form `-n' is given, +and it is meant to denote a process group, +either the signal must be specified first, or the argument must be preceded +by a `--' option, otherwise it will be taken as the signal to send. +.TP +.I commandname +All processes invoked using that name will be signaled. +.RE .TP -.BR \-s +.BI \-s " signal" Specify the signal to send. The signal may be given as a signal name or number. .TP -.BR \-p -Specify that -.B kill -should only print the process id -.I (pid) -of the named process, and should not send it a signal. -.TP -.BR \-l +.B \-l Print a list of signal names. These are found in .I /usr/include/linux/signal.h +.TP +.B \-a +Do not restrict the commandname-to-pid conversion to processes +with the same uid as the present process. +.TP +.B \-p +Specify that +.B kill +should only print the process id (pid) +of the named processes, and not send any signals. .SH "SEE ALSO" .BR bash (1), .BR tcsh (1), .BR kill (2), -.BR sigvec (2) +.BR sigvec (2), +.BR signal (7) .SH AUTHOR Taken from BSD 4.4. The ability to translate process names to process ids was added by Salvatore Valente . diff --git a/misc-utils/kill.c b/misc-utils/kill.c index ea4e4682d..65100236c 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -35,7 +35,7 @@ * modifications (c) salvatore valente * may be used / modified / distributed under the same terms as the original. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * 1999-11-13 aeb Accept signal numers 128+s. @@ -149,12 +149,12 @@ int kill_verbose (char *procname, int pid, int sig); extern int *get_pids (char *, int); -char *whoami; +static char *progname; int main (int argc, char *argv[]) { int errors, numsig, pid; - char *ep, *arg, *progname, *p; + char *ep, *arg, *p; int do_pid, do_kill, check_all; int *pids, *ip; @@ -166,9 +166,8 @@ int main (int argc, char *argv[]) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - whoami = mybasename (*argv); numsig = SIGTERM; - do_pid = (! strcmp (whoami, "pid")); + do_pid = (! strcmp (progname, "pid")); /* Yecch */ do_kill = 0; check_all = 0; @@ -184,9 +183,6 @@ int main (int argc, char *argv[]) argc--, argv++; break; } - if (! strcmp (arg, "-u")) { - return usage (0); - } if (! strcmp (arg, "-v") || ! strcmp (arg, "-V") || ! strcmp (arg, "--version")) { printf(_("%s from %s\n"), progname, util_linux_version); @@ -207,7 +203,7 @@ int main (int argc, char *argv[]) /* argc == 2, accept "kill -l $?" */ arg = argv[1]; if ((numsig = arg_to_signum (arg, 1)) < 0) { - fprintf (stderr, _("%s: unknown signal %s\n"), whoami, arg); + fprintf (stderr, _("%s: unknown signal %s\n"), progname, arg); return 1; } printsig (numsig); @@ -238,6 +234,7 @@ int main (int argc, char *argv[]) so it's probably something like -HUP, or -1/-n try to deal with it. -n could be signal n, or pid -n (i.e. process group n). + In case of doubt POSIX tells us to assume a signal. If a signal has been parsed, assume it's a pid, break */ if (do_kill) break; @@ -270,7 +267,7 @@ int main (int argc, char *argv[]) if (! pids) { errors++; fprintf (stderr, _("%s: can't find process \"%s\"\n"), - whoami, arg); + progname, arg); continue; } for (ip = pids; *ip >= 0; ip++) @@ -313,7 +310,7 @@ int arg_to_signum (char *arg, int maskbit) void nosig (char *name) { - fprintf (stderr, _("%s: unknown signal %s; valid signals:\n"), whoami, name); + fprintf (stderr, _("%s: unknown signal %s; valid signals:\n"), progname, name); printsignals (stderr); } @@ -353,8 +350,8 @@ int usage (int status) FILE *fp; fp = (status == 0 ? stdout : stderr); - fprintf (fp, _("usage: %s [ -s signal | -p ] [ -a ] pid ...\n"), whoami); - fprintf (fp, _(" %s -l [ signal ]\n"), whoami); + fprintf (fp, _("usage: %s [ -s signal | -p ] [ -a ] pid ...\n"), progname); + fprintf (fp, _(" %s -l [ signal ]\n"), progname); return status; } @@ -365,7 +362,7 @@ int kill_verbose (char *procname, int pid, int sig) return 0; } if (kill (pid, sig) < 0) { - fprintf (stderr, "%s ", whoami); + fprintf (stderr, "%s ", progname); perror (procname); return 1; } diff --git a/misc-utils/logger.c b/misc-utils/logger.c index ae0ebec00..e00578735 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * Sun Mar 21 1999 - Arnaldo Carvalho de Melo * - fixed strerr(errno) in gettext calls diff --git a/misc-utils/look.c b/misc-utils/look.c index d601e1c97..f3b4ba517 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ - /* 1999-02-22 Arkadiusz Mi¶kiewicz + /* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c index 9f13b49d1..6930745b2 100644 --- a/misc-utils/mcookie.c +++ b/misc-utils/mcookie.c @@ -14,7 +14,7 @@ * gather 128 bits of random information, so the magic cookie generated * will be considerably easier to guess than one might expect. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * 1999-03-21 aeb: Added some fragments of code from Colin Plumb. * diff --git a/misc-utils/namei.c b/misc-utils/namei.c index f77d501c4..783c5b9b6 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -39,7 +39,7 @@ the maximum number of symbolic links this system can have. The program exits with a 1 status ONLY if it finds it cannot chdir to /, or if it encounters an unknown file type. -1999-02-22 Arkadiusz Mi¶kiewicz +1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support -------------------------------------------------------------*/ diff --git a/misc-utils/script.c b/misc-utils/script.c index c3bf142e6..951fc763d 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -32,7 +32,7 @@ */ /* - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * 2000-07-30 Per Andreas Buer - added "q"-option diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c index 92161d01c..2e265fc51 100644 --- a/misc-utils/setterm.c +++ b/misc-utils/setterm.c @@ -16,7 +16,7 @@ * * Converted to terminfo by Kars de Jong (jongk@cs.utwente.nl) * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * * @@ -859,17 +859,17 @@ perform_sequence(int vcterm) { /* -snow [on|off]. Vc only. */ if (opt_snow && vcterm) { if (opt_sn_on) - printf("%s%s%s", DCS, _("snow.on"), ST); + printf("%s%s%s", DCS, "snow.on", ST); else - printf("%s%s%s", DCS, _("snow.off"), ST); + printf("%s%s%s", DCS, "snow.off", ST); } /* -softscroll [on|off]. Vc only. */ if (opt_softscroll && vcterm) { if (opt_so_on) - printf("%s%s%s", DCS, _("softscroll.on"), ST); + printf("%s%s%s", DCS, "softscroll.on", ST); else - printf("%s%s%s", DCS, _("softscroll.off"), ST); + printf("%s%s%s", DCS, "softscroll.off", ST); } #endif @@ -1165,6 +1165,7 @@ try_ioctl: } rows = screenbuf[0]; cols = screenbuf[1]; + for (i=0; i - * - added Native Language Support - */ - -#include -#include -#include -#include -#include -#include -#include "nls.h" - -/* - * Topological sort. Input is a list of pairs of strings seperated by - * white space (spaces, tabs, and/or newlines); strings are written to - * standard output in sorted order, one per line. - * - * usage: - * tsort [inputfile] - * If no input file is specified, standard input is read. - * - * Should be compatable with AT&T tsort HOWEVER the output is not identical - * (i.e. for most graphs there is more than one sorted order, and this tsort - * usually generates a different one then the AT&T tsort). Also, cycle - * reporting seems to be more accurate in this version (the AT&T tsort - * sometimes says a node is in a cycle when it isn't). - * - * Michael Rendell, michael@stretch.cs.mun.ca - Feb 26, '90 - */ -#define HASHSIZE 53 /* doesn't need to be big */ -#define NF_MARK 0x1 /* marker for cycle detection */ -#define NF_ACYCLIC 0x2 /* this node is cycle free */ - -typedef struct node_str NODE; - -struct node_str { - char *n_name; /* name of this node */ - NODE **n_prevp; /* pointer to previous node's n_next */ - NODE *n_next; /* next node in graph */ - NODE *n_hash; /* next node in hash table */ - int n_narcs; /* number of arcs in n_arcs[] */ - int n_arcsize; /* size of n_arcs[] array */ - NODE **n_arcs; /* array of arcs to other nodes */ - int n_refcnt; /* # of arcs pointing to this node */ - int n_flags; /* NF_* */ -}; - -typedef struct _buf { - char *b_buf; - int b_bsize; -} BUF; - -NODE *add_node(char *), *find_node(char *); -void add_arc(char *, char *), no_memory(void); -void remove_node(NODE *), tsort(void); -char *grow_buf(char *, int); -int find_cycle(NODE *, NODE *, int, int); - -NODE *graph; -NODE *hashtable[HASHSIZE]; -NODE **cycle_buf; -NODE **longest_cycle; - -int -main(int argc, char **argv) { - BUF *b; - int c, n; - FILE *fp; - int bsize, nused; - BUF bufs[2]; - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - if (argc < 2) - fp = stdin; - /* == becomes > in next line per Volker Meyer_zu_Bexten - -- faith@cs.unc.edu, Sat Feb 4 21:25:09 1995 */ - else if (argc > 2) { - (void)fprintf(stderr, _("usage: tsort [ inputfile ]\n")); - exit(1); - } else if (!(fp = fopen(argv[1], "r"))) { - (void)fprintf(stderr, "tsort: %s.\n", strerror(errno)); - exit(1); - } - - for (b = bufs, n = 2; --n >= 0; b++) - b->b_buf = grow_buf((char *)NULL, b->b_bsize = 1024); - - /* parse input and build the graph */ - for (n = 0, c = getc(fp);;) { - while (c != EOF && isspace(c)) - c = getc(fp); - if (c == EOF) - break; - - nused = 0; - b = &bufs[n]; - bsize = b->b_bsize; - do { - b->b_buf[nused++] = c; - if (nused == bsize) { - bsize *= 2; - b->b_buf = grow_buf(b->b_buf, bsize); - } - c = getc(fp); - } while (c != EOF && !isspace(c)); - - b->b_buf[nused] = '\0'; - b->b_bsize = bsize; - if (n) - add_arc(bufs[0].b_buf, bufs[1].b_buf); - n = !n; - } - (void)fclose(fp); - if (n) { - (void)fprintf(stderr, _("tsort: odd data count.\n")); - exit(1); - } - - /* do the sort */ - tsort(); - return 0; -} - -/* double the size of oldbuf and return a pointer to the new buffer. */ -char * -grow_buf(char *bp, int size) { - if (!(bp = realloc(bp, (u_int)size))) - no_memory(); - return(bp); -} - -/* - * add an arc from node s1 to node s2 in the graph. If s1 or s2 are not in - * the graph, then add them. - */ -void -add_arc(char *s1, char *s2) { - NODE *n1; - NODE *n2; - int bsize; - - n1 = find_node(s1); - if (!n1) - n1 = add_node(s1); - - if (!strcmp(s1, s2)) - return; - - n2 = find_node(s2); - if (!n2) - n2 = add_node(s2); - - /* - * could check to see if this arc is here already, but it isn't - * worth the bother -- there usually isn't and it doesn't hurt if - * there is (I think :-). - */ - if (n1->n_narcs == n1->n_arcsize) { - if (!n1->n_arcsize) - n1->n_arcsize = 10; - bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2; - n1->n_arcs = (NODE **)grow_buf((char *)n1->n_arcs, bsize); - n1->n_arcsize = bsize / sizeof(*n1->n_arcs); - } - n1->n_arcs[n1->n_narcs++] = n2; - ++n2->n_refcnt; -} - -static int -hash_string(char *s) { - int hash, i; - - for (hash = 0, i = 1; *s; s++, i++) - hash += *s * i; - return(hash % HASHSIZE); -} - -/* - * find a node in the graph and return a pointer to it - returns null if not - * found. - */ -NODE * -find_node(char *name) { - NODE *n; - - for (n = hashtable[hash_string(name)]; n; n = n->n_hash) - if (!strcmp(n->n_name, name)) - return(n); - return((NODE *)NULL); -} - -/* Add a node to the graph and return a pointer to it. */ -NODE * -add_node(char *name) { - NODE *n; - int hash; - - if (!(n = (NODE *)malloc(sizeof(NODE))) || !(n->n_name = strdup(name))) - no_memory(); - - n->n_narcs = 0; - n->n_arcsize = 0; - n->n_arcs = (NODE **)NULL; - n->n_refcnt = 0; - n->n_flags = 0; - - /* add to linked list */ - if ((n->n_next = graph) != NULL) - graph->n_prevp = &n->n_next; - n->n_prevp = &graph; - graph = n; - - /* add to hash table */ - hash = hash_string(name); - n->n_hash = hashtable[hash]; - hashtable[hash] = n; - return(n); -} - -/* do topological sort on graph */ -void -tsort(void) { - NODE *n, *next; - int cnt; - - while (graph) { - /* - * keep getting rid of simple cases until there are none left, - * if there are any nodes still in the graph, then there is - * a cycle in it. - */ - do { - for (cnt = 0, n = graph; n; n = next) { - next = n->n_next; - if (n->n_refcnt == 0) { - remove_node(n); - ++cnt; - } - } - } while (graph && cnt); - - if (!graph) - break; - - if (!cycle_buf) { - /* - * allocate space for two cycle logs - one to be used - * as scratch space, the other to save the longest - * cycle. - */ - for (cnt = 0, n = graph; n; n = n->n_next) - ++cnt; - cycle_buf = - (NODE **)malloc((u_int)sizeof(NODE *) * cnt); - longest_cycle = - (NODE **)malloc((u_int)sizeof(NODE *) * cnt); - if (!cycle_buf || !longest_cycle) - no_memory(); - } - for (n = graph; n; n = n->n_next) - if (!(n->n_flags & NF_ACYCLIC)) { - if ((cnt = find_cycle(n, n, 0, 0)) != 0) { - int i; - - (void)fprintf(stderr, - _("tsort: cycle in data.\n")); - for (i = 0; i < cnt; i++) - (void)fprintf(stderr, - "tsort: %s.\n", longest_cycle[i]->n_name); - remove_node(n); - break; - } else - /* to avoid further checks */ - n->n_flags = NF_ACYCLIC; - } - - if (!n) { - (void)fprintf(stderr, - _("tsort: internal error -- could not find cycle.\n")); - exit(1); - } - } -} - -/* print node and remove from graph (does not actually free node) */ -void -remove_node(NODE *n) { - NODE **np; - int i; - - (void)printf("%s\n", n->n_name); - for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++) - --(*np)->n_refcnt; - n->n_narcs = 0; - *n->n_prevp = n->n_next; - if (n->n_next) - n->n_next->n_prevp = n->n_prevp; -} - -/* look for the longest cycle from node from to node to. */ -int -find_cycle(NODE *from, NODE *to, int longest_len, int depth) { - NODE **np; - int i, len; - - /* - * avoid infinite loops and ignore portions of the graph known - * to be acyclic - */ - if (from->n_flags & (NF_MARK|NF_ACYCLIC)) - return(0); - from->n_flags = NF_MARK; - - for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) { - cycle_buf[depth] = *np; - if (*np == to) { - if (depth + 1 > longest_len) { - longest_len = depth + 1; - (void)memcpy((char *)longest_cycle, - (char *)cycle_buf, - longest_len * sizeof(NODE *)); - } - } else { - len = find_cycle(*np, to, longest_len, depth + 1); - if (len > longest_len) - longest_len = len; - } - } - from->n_flags &= ~NF_MARK; - return(longest_len); -} - -void -no_memory(void) { - (void)fprintf(stderr, "tsort: %s.\n", strerror(ENOMEM)); - exit(1); -} diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 239b1f4ae..385cbf41b 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -33,7 +33,7 @@ /* *:aeb */ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support */ diff --git a/misc-utils/write.c b/misc-utils/write.c index e794a4eee..b3c96d14c 100644 --- a/misc-utils/write.c +++ b/misc-utils/write.c @@ -40,7 +40,7 @@ * - Added fix from David.Chapell@mail.trincoll.edu enabeling daemons * to use write. * - ANSIed it since I was working on it anyway. - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * */ @@ -197,11 +197,7 @@ void search_utmp(char *user, char *tty, char *mytty, uid_t myuid) struct utmp *uptr; time_t bestatime, atime; int nloggedttys, nttys, msgsok, user_is_me; -#ifdef __linux__ char atty[sizeof(u.ut_line) + 1]; -#else - char atty[UT_LINESIZE + 1]; -#endif utmpname(_PATH_UTMP); setutent(); @@ -213,13 +209,8 @@ void search_utmp(char *user, char *tty, char *mytty, uid_t myuid) memcpy(&u, uptr, sizeof(u)); if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0) { ++nloggedttys; -#ifdef __linux__ (void)strncpy(atty, u.ut_line, sizeof(u.ut_line)); atty[sizeof(u.ut_line)] = '\0'; -#else - (void)strncpy(atty, u.ut_line, UT_LINESIZE); - atty[UT_LINESIZE] = '\0'; -#endif if (term_chk(atty, &msgsok, &atime, 0)) continue; /* bad term? skip */ if (myuid && !msgsok) @@ -228,10 +219,8 @@ void search_utmp(char *user, char *tty, char *mytty, uid_t myuid) user_is_me = 1; continue; /* don't write to yourself */ } -#ifdef __linux__ if (u.ut_type != USER_PROCESS) continue; /* it's not a valid entry */ -#endif ++nttys; if (atime > bestatime) { bestatime = atime; diff --git a/mount/Makefile b/mount/Makefile index 18e30cde6..ef65601f7 100644 --- a/mount/Makefile +++ b/mount/Makefile @@ -24,14 +24,10 @@ PROGS = $(SUID_PROGS) $(NOSUID_PROGS) MAYBE = pivot_root swapoff -# comment these out if you are not compiling in NFS support +LO_OBJS = lomount.o $(LIB)/xstrncpy.o NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o -# uncomment this if you don't have libc-4.2 but do have the rpclib GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c -# comment these out if you are not compiling in loop support -LO_OBJS=lomount.o - all: $(PROGS) install: $(PROGS) @@ -58,10 +54,10 @@ umount: umount.o fstab.o sundries.o realpath.o mntent.o getusername.o \ swapon: swapon.o version.o $(LINK) $^ -o $@ -losetup.o: lomount.c +main_losetup.o: lomount.c $(COMPILE) -DMAIN lomount.c -o $@ -losetup: losetup.o +losetup: main_losetup.o $(LIB)/xstrncpy.o $(LINK) $^ -o $@ mount.o umount.o nfsmount.o losetup.o fstab.o realpath.o sundries.o: sundries.h diff --git a/mount/fstab.5 b/mount/fstab.5 index 6d7638e4a..608f81d82 100644 --- a/mount/fstab.5 +++ b/mount/fstab.5 @@ -76,9 +76,11 @@ For NFS mounts one will have :, e.g., `knuth.aeb.nl:/'. For procfs, use `proc'. .LP Instead of giving the device explicitly, one may indicate -the (ext2) filesystem that is to be mounted by its UUID or +the (ext2 or XFS) filesystem that is to be mounted by its UUID or volume label (cf. -.BR e2label (8)), +.BR e2label (8) +or +.BR xfs_admin (8)), writing LABEL=