debian/0000755000000000000000000000000012222102741007157 5ustar debian/stamp-makefile-build0000644000000000000000000000000011740504131013067 0ustar debian/postrm0000644000000000000000000000022711740504130010431 0ustar #! /bin/sh set -e case "$1" in purge) rm -rf /var/lib/sash/ ;; remove) remove-shell /bin/sash ;; esac #DEBHELPER# debian/control0000644000000000000000000000335012222044524010567 0ustar Source: sash Section: shells Priority: optional Maintainer: Tollef Fog Heen Standards-Version: 3.9.4 Build-Depends: zlib1g-dev (>= 1:1.2.2-7), debhelper (>= 9), e2fslibs-dev [!kfreebsd-amd64 !kfreebsd-i386], kfreebsd-kernel-headers [kfreebsd-amd64 kfreebsd-i386] Package: sash Architecture: any Section: shells Priority: optional Depends: ${shlibs:Depends}, ${misc:Depends} Suggests: doc-debian Built-Using: ${built-using} Description: Stand-alone shell sash serves as an interactive substitute for /bin/sh, for use when /bin/sh is unusable. It's statically linked, and includes many standard utilities as builtins (type "help" at the prompt for a reference list). If you've installed sash before rendering your system unbootable, and you have some knowledge of how your system is supposed to work, you might be able to repair your system using init=/bin/sash at the boot prompt. . Some people also prefer to have sash available as the shell for a root account (perhaps an under an alternate name such as sashroot) Configuration support is included for people who want this. . Note: sash is not intended to serve as /bin/sh, and has few of the interactive features present in bash or ksh. It's designed to be simple and robust, for people who need to do emergency repair work on a system. . Also note: sash doesn't include a built-in fsck -- fsck is too big and complicated. If you need fsck, you'll have to get at least one partition or disk working well enough to run fsck. More generally, sash is but one tool of many (backups, backup recovery tools, emergency boot disks or partitions, spare parts, testing of disaster plans, etc.) to help you recover a damaged system. Homepage: http://members.tip.net.au/~dbell/ debian/README.debian0000644000000000000000000000366211740504123011273 0ustar sash for DEBIAN -------------------------- [random tips and comments] -------------------------- In an emergency, you can run linux (just barely) with just the linux kernel, a boot loader (such as lilo), and /bin/sash. Use the boot loader to start linux with the option: init=/bin/sash For a list of built-in sash commands, type help You may or may not be able to log in using sash on a damaged system. People with real experience on damaged systems who have simple suggestions on how sash could be made more robust in this circumstance are invited to file wishlist bugs against the sash package. If you wish to avoid the overhead of rebooting in an emergency the best option is probably to keep a sash root account always logged in. This can be a security problem unless you lock the session with a program such as vlock. At the moment, vlock is only useful at the linux console. -------------------------- To take apart a debian .deb file with sash, use -ar x filename.deb This will create three files: control.tar.gz data.tar.gz debian-binary See section 7 of the debian FAQ (and the documentation it references) for more details on the contents of the two tar.gz files (a copy of the debian FAQ is supplied in the doc-debian package). -------------------------- If you plan on being able to use sash for emergency repair work, make sure that you understand what each of the built in commands does. This is best accomplished by reading the manual page for the full featured counterpart, and performing some controlled tests under non-emergency conditions. It's probably a also good idea to have a small partition with a copy of the debian base system on it. There are some good low-level tools for creating/repairing file systems, sash doesn't substitute for these. Also, sash doesn't provide any networking tools. It's a good idea to have a stock of rescue floppies, and distribution cdroms. And none of these precautions substitute for decent backups. debian/compat0000644000000000000000000000000212222032370010355 0ustar 9 debian/copyright0000644000000000000000000000175311740504124011125 0ustar This package was debianized by Michael Meskes on Tue, 16 Dec 1997 11:05:51 +0100, and is currently being maintained by Tollef Fog Heen . Please see the Debian changelog for the history of who maintained the package when. It was downloaded from http://www.tip.net.au/~dbell/programs/sash-3.4.tar.gz New versions will probably be announced at http://www.tip.net.au/~dbell/. Copyright: * Copyright (c) 1998 by David I. Bell * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. The code for the internal ar command has the copyright: * Original: * Copyright (c) 1999 by Aaron R. Crane. * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * * Modified: * Copyright (c) 1999 by David I. Bell * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. debian/postinst0000644000000000000000000000057511740504130010776 0ustar #! /bin/sh # postinst for sash # set -e if [ "$1" = "configure" ] && [ "$2" = "" ] || dpkg --compare-versions "$2" lt "3.7-7.3"; then # initial install or upgrade from old version which didn't call # add-shell properly. add-shell /bin/sash fi # Make sure we get rid of any stuff in /usr/doc if [ -L "/usr/doc/sash" ]; then rm -f "/usr/doc/sash" fi #DEBHELPER# debian/menu0000644000000000000000000000013311740504127010053 0ustar ?package(sash):needs="text" section="Applications/Shells" title="Sash" command="/bin/sash" debian/rules0000755000000000000000000000115112222045144010240 0ustar #! /usr/bin/make -f pkgdir := `pwd`/debian/sash BUILT_USING := $(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W zlib1g-dev libc6-dev) %: dh $@ override_dh_auto_build: $(MAKE) CFLAGS="`dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS`" LDFLAGS="-static `dpkg-buildflags --get LDFLAGS`" override_dh_auto_install: make install BINDIR=$(pkgdir)/bin MANDIR=$(pkgdir)/usr/share/man/man1 override_dh_install: dh_install install -m 0644 debian/lintian-overrides $(pkgdir)/usr/share/lintian/overrides/sash override_dh_gencontrol: dh_gencontrol -- -V"built-using=$(BUILT_USING)" debian/prerm0000644000000000000000000000065111740504127010241 0ustar #!/bin/sh # prerm for sash # make sure that accounts using sash will # at least continue to work after sash is removed... set -e if [ "$1" = remove ]; then if [ "$(getent passwd | grep ^sashroot:)" != "" ]; then userdel sashroot fi for sashacct in $(getent passwd | \ awk -F: '{if ($7 == "/bin/sash") {print $1}}'); do chsh -s /bin/bash $sashacct || true done fi #DEBHELPER# exit 0 debian/dirs0000644000000000000000000000006411740504130010045 0ustar bin usr/share/man/man1 usr/share/lintian/overrides/ debian/source/0000755000000000000000000000000011740504131010462 5ustar debian/source/format0000644000000000000000000000001411740504131011670 0ustar 3.0 (quilt) debian/patches/0000755000000000000000000000000011740510070010610 5ustar debian/patches/buildsystem0000644000000000000000000000137511740504131013106 0ustar Index: sash-3.7/Makefile =================================================================== --- sash-3.7.orig/Makefile 2010-04-04 10:13:55.176949485 +0200 +++ sash-3.7/Makefile 2010-04-04 10:14:03.300968030 +0200 @@ -13,13 +13,12 @@ HAVE_BSD_MOUNT = 0 MOUNT_TYPE = '"ext3"' - -CFLAGS = -O3 -Wall -Wmissing-prototypes \ - -DHAVE_GZIP=$(HAVE_GZIP) \ +DEFS = -DHAVE_GZIP=$(HAVE_GZIP) \ -DHAVE_LINUX_ATTR=$(HAVE_LINUX_ATTR) \ -DHAVE_LINUX_MOUNT=$(HAVE_LINUX_MOUNT) \ -DHAVE_BSD_MOUNT=$(HAVE_BSD_MOUNT) \ -DMOUNT_TYPE=$(MOUNT_TYPE) +CFLAGS = -O3 -Wall -Wmissing-prototypes -g $(DEFS) LDFLAGS = -static -s LIBS = -lz @@ -43,4 +42,7 @@ cp sash $(BINDIR)/sash cp sash.1 $(MANDIR)/sash.1 +%.o: %.c + $(CC) $(CFLAGS) $(DEFS) -c $< + $(OBJS): sash.h debian/patches/__inactive__exit_with_command_status0000644000000000000000000007776311740504131020204 0ustar Index: sash-3.7/cmds.c =================================================================== --- sash-3.7.orig/cmds.c 2010-04-04 11:45:33.864951850 +0200 +++ sash-3.7/cmds.c 2010-04-04 12:29:17.184954241 +0200 @@ -26,7 +26,7 @@ #endif -void +int do_echo(int argc, const char ** argv) { BOOL first; @@ -43,10 +43,11 @@ } fputc('\n', stdout); + return 0; } -void +int do_pwd(int argc, const char ** argv) { char buf[PATH_LEN]; @@ -55,14 +56,15 @@ { fprintf(stderr, "Cannot get current directory\n"); - return; + return 1; } printf("%s\n", buf); + return 0; } -void +int do_cd(int argc, const char ** argv) { const char * path; @@ -77,29 +79,38 @@ { fprintf(stderr, "No HOME environment variable\n"); - return; + return 1; } } if (chdir(path) < 0) + { perror(path); + return 1; + } + return 0; } -void +int do_mkdir(int argc, const char ** argv) { + int r = 0; while (argc-- > 1) { if (mkdir(argv[1], 0777) < 0) + { perror(argv[1]); + r = 1; + } argv++; } + return r; } -void +int do_mknod(int argc, const char ** argv) { const char * cp; @@ -117,7 +128,7 @@ { fprintf(stderr, "Bad device type\n"); - return; + return 1; } major = 0; @@ -130,7 +141,7 @@ { fprintf(stderr, "Bad major number\n"); - return; + return 1; } minor = 0; @@ -143,53 +154,70 @@ { fprintf(stderr, "Bad minor number\n"); - return; + return 1; } if (mknod(argv[1], mode, major * 256 + minor) < 0) + { perror(argv[1]); + return 1; + } + return 0; } -void +int do_rmdir(int argc, const char ** argv) { + int r = 0; while (argc-- > 1) { if (rmdir(argv[1]) < 0) + { perror(argv[1]); + r = 1; + } argv++; } + return r; } -void +int do_sync(int argc, const char ** argv) { sync(); + return 0; } -void +int do_rm(int argc, const char ** argv) { + int r = 0; while (argc-- > 1) { if (unlink(argv[1]) < 0) + { perror(argv[1]); + r = 1; + } argv++; } + return r; } -void +int do_chmod(int argc, const char ** argv) { const char * cp; int mode; + int r; + r = 0; mode = 0; cp = argv[1]; @@ -200,7 +228,7 @@ { fprintf(stderr, "Mode must be octal\n"); - return; + return 1; } argc--; @@ -209,21 +237,27 @@ while (argc-- > 1) { if (chmod(argv[1], mode) < 0) + { perror(argv[1]); + r = 1; + } argv++; } + return r; } -void +int do_chown(int argc, const char ** argv) { const char * cp; int uid; struct passwd * pwd; struct stat statBuf; + int r; + r = 0; cp = argv[1]; if (isDecimal(*cp)) @@ -237,7 +271,7 @@ { fprintf(stderr, "Bad uid value\n"); - return; + return 1; } } else { pwd = getpwnam(cp); @@ -246,7 +280,7 @@ { fprintf(stderr, "Unknown user name\n"); - return; + return 1; } uid = pwd->pw_uid; @@ -263,19 +297,23 @@ (chown(*argv, uid, statBuf.st_gid) < 0)) { perror(*argv); + r = 1; } } + return r; } -void +int do_chgrp(int argc, const char ** argv) { const char * cp; int gid; struct group * grp; struct stat statBuf; + int r; + r = 0; cp = argv[1]; if (isDecimal(*cp)) @@ -289,7 +327,7 @@ { fprintf(stderr, "Bad gid value\n"); - return; + return 1; } } else @@ -300,7 +338,7 @@ { fprintf(stderr, "Unknown group name\n"); - return; + return 1; } gid = grp->gr_gid; @@ -317,18 +355,22 @@ (chown(*argv, statBuf.st_uid, gid) < 0)) { perror(*argv); + r = 1; } } + return r; } -void +int do_touch(int argc, const char ** argv) { const char * name; int fd; struct utimbuf now; + int r; + r = 0; time(&now.actime); now.modtime = now.actime; @@ -347,23 +389,30 @@ if (errno != EEXIST) { perror(name); + r = 1; continue; } if (utime(name, &now) < 0) + { perror(name); + r = 1; + } } + return r; } -void +int do_mv(int argc, const char ** argv) { const char * srcName; const char * destName; const char * lastArg; BOOL dirFlag; + int r; + r = 0; lastArg = argv[argc - 1]; dirFlag = isDirectory(lastArg); @@ -372,7 +421,7 @@ { fprintf(stderr, "%s: not a directory\n", lastArg); - return; + return 1; } while (!intFlag && (argc-- > 2)) @@ -382,6 +431,7 @@ if (access(srcName, 0) < 0) { perror(srcName); + r = 1; continue; } @@ -397,6 +447,7 @@ if (errno != EXDEV) { perror(destName); + r = 1; continue; } @@ -405,18 +456,25 @@ continue; if (unlink(srcName) < 0) + { perror(srcName); + r = 1; + } } + return r; } -void +int do_ln(int argc, const char ** argv) { const char * srcName; const char * destName; const char * lastArg; BOOL dirFlag; + int r; + + r = 0; if (argv[1][0] == '-') { @@ -424,23 +482,27 @@ { fprintf(stderr, "Unknown option\n"); - return; + return 1; } if (argc != 4) { fprintf(stderr, "Wrong number of arguments for symbolic link\n"); - return; + return 1; } #ifdef S_ISLNK if (symlink(argv[2], argv[3]) < 0) + { perror(argv[3]); + return 1; + } + return 0; #else fprintf(stderr, "Symbolic links are not allowed\n"); + return 1; #endif - return; } /* @@ -453,7 +515,7 @@ { fprintf(stderr, "%s: not a directory\n", lastArg); - return; + return 1; } while (argc-- > 2) @@ -463,6 +525,7 @@ if (access(srcName, 0) < 0) { perror(srcName); + r = 1; continue; } @@ -475,21 +538,25 @@ if (link(srcName, destName) < 0) { perror(destName); + r = 1; continue; } } + return r; } -void +int do_cp(int argc, const char ** argv) { const char * srcName; const char * destName; const char * lastArg; BOOL dirFlag; + int r; + r = 0; lastArg = argv[argc - 1]; dirFlag = isDirectory(lastArg); @@ -498,7 +565,7 @@ { fprintf(stderr, "%s: not a directory\n", lastArg); - return; + return 1; } while (!intFlag && (argc-- > 2)) @@ -509,12 +576,14 @@ if (dirFlag) destName = buildName(destName, srcName); - (void) copyFile(srcName, destName, FALSE); + if (!copyFile(srcName, destName, FALSE)) + r = 1; } + return r; } -void +int do_mount(int argc, const char ** argv) { const char * str; @@ -544,7 +613,7 @@ { fprintf(stderr, "Missing file system type\n"); - return; + return 1; } type = *argv++; @@ -584,7 +653,7 @@ default: fprintf(stderr, "Unknown option\n"); - return; + return 1; } } @@ -592,14 +661,16 @@ { fprintf(stderr, "Wrong number of arguments for mount\n"); - return; + return 1; } #if HAVE_LINUX_MOUNT - if (mount(argv[0], argv[1], type, flags, 0) < 0) - perror("mount failed"); - + if (mount(argv[0], argv[1], type, flags, 0) < 0) + { + perror("mount failed"); + return 1; + } #elif HAVE_BSD_MOUNT { struct ufs_args ufs; @@ -622,22 +693,29 @@ fprintf(stderr, "Unknown filesystem type: %s", type); fprintf(stderr, "Supported: ffs ufs adosfs cd9660 mfs msdos\n"); - return; + return 1; } if (mount(type, argv[1], flags, args) < 0) - perror(argv[0]); + { + perror(argv[0]); + return 1; + } } #endif + return 0; } -void +int do_umount(int argc, const char ** argv) { #if HAVE_LINUX_MOUNT if (umount(argv[1]) < 0) + { perror(argv[1]); + return 1; + } #elif HAVE_BSD_MOUNT { const char * str; @@ -659,13 +737,17 @@ } if (unmount(argv[0], flags) < 0) + { perror(argv[0]); + return 1; + } } #endif + return 0; } -void +int do_cmp(int argc, const char ** argv) { int fd1; @@ -679,19 +761,22 @@ char buf2[BUF_SIZE]; struct stat statBuf1; struct stat statBuf2; + int r; + + r = 0; if (stat(argv[1], &statBuf1) < 0) { perror(argv[1]); - return; + return 1; } if (stat(argv[2], &statBuf2) < 0) { perror(argv[2]); - return; + return 1; } if ((statBuf1.st_dev == statBuf2.st_dev) && @@ -699,14 +784,14 @@ { printf("Files are links to each other\n"); - return; + return 0; } if (statBuf1.st_size != statBuf2.st_size) { printf("Files are different sizes\n"); - return; + return 1; } fd1 = open(argv[1], O_RDONLY); @@ -715,7 +800,7 @@ { perror(argv[1]); - return; + return 1; } fd2 = open(argv[2], O_RDONLY); @@ -725,7 +810,7 @@ perror(argv[2]); close(fd1); - return; + return 1; } pos = 0; @@ -740,6 +825,7 @@ if (cc1 < 0) { perror(argv[1]); + r = 1; goto closefiles; } @@ -748,24 +834,28 @@ if (cc2 < 0) { perror(argv[2]); + r = 1; goto closefiles; } if ((cc1 == 0) && (cc2 == 0)) { printf("Files are identical\n"); + r = 0; goto closefiles; } if (cc1 < cc2) { printf("First file is shorter than second\n"); + r = 1; goto closefiles; } if (cc1 > cc2) { printf("Second file is shorter than first\n"); + r = 1; goto closefiles; } @@ -783,6 +873,7 @@ pos++; printf("Files differ at byte position %ld\n", pos); + r = 1; goto closefiles; } @@ -790,10 +881,11 @@ closefiles: close(fd1); close(fd2); + return r; } -void +int do_more(int argc, const char ** argv) { FILE * fp; @@ -841,7 +933,7 @@ { perror(name); - return; + return 1; } printf("<< %s >>\n", name); @@ -896,7 +988,7 @@ if (fp) fclose(fp); - return; + return 0; } ch = buf[0]; @@ -916,7 +1008,7 @@ case 'q': fclose(fp); - return; + return 0; } col = 0; @@ -926,10 +1018,11 @@ if (fp) fclose(fp); } + return 0; } -void +int do_sum(int argc, const char ** argv) { const char * name; @@ -939,9 +1032,11 @@ int i; unsigned long checksum; char buf[BUF_SIZE]; + int r; argc--; argv++; + r = 0; while (argc-- > 0) { @@ -952,6 +1047,7 @@ if (fd < 0) { perror(name); + r = 1; continue; } @@ -976,6 +1072,7 @@ if (cc < 0) { perror(name); + r = 1; (void) close(fd); @@ -986,10 +1083,11 @@ printf("%05lu %s\n", checksum, name); } + return r; } -void +int do_exit(int argc, const char ** argv) { int r = 0; @@ -997,17 +1095,18 @@ { fprintf(stderr, "You are the INIT process!\n"); - return; + return 1; } if (argc == 2) { r = atoi(argv[1]); } exit(r); + return r; } -void +int do_setenv(int argc, const char ** argv) { const char * name; @@ -1027,7 +1126,7 @@ { fprintf(stderr, "Cannot allocate memory\n"); - return; + return 1; } strcpy(str, name); @@ -1035,10 +1134,11 @@ strcat(str, value); putenv(str); + return 0; } -void +int do_printenv(int argc, const char ** argv) { const char ** env; @@ -1052,7 +1152,7 @@ while (*env) printf("%s\n", *env++); - return; + return 0; } len = strlen(argv[1]); @@ -1064,14 +1164,15 @@ { printf("%s\n", &env[0][len+1]); - return; + return 0; } env++; } + return 0; } -void +int do_umask(int argc, const char ** argv) { const char * cp; @@ -1083,7 +1184,7 @@ umask(mask); printf("%03o\n", mask); - return; + return 0; } mask = 0; @@ -1096,20 +1197,24 @@ { fprintf(stderr, "Bad umask value\n"); - return; + return 1; } umask(mask); + return 0; + } -void +int do_kill(int argc, const char ** argv) { const char * cp; int sig; int pid; + int r; + r = 0; sig = SIGTERM; if (argv[1][0] == '-') @@ -1145,7 +1250,7 @@ { fprintf(stderr, "Unknown signal\n"); - return; + return 1; } } @@ -1165,16 +1270,20 @@ { fprintf(stderr, "Non-numeric pid\n"); - return; + return 1; } if (kill(pid, sig) < 0) + { perror(*argv); + r = 1; + } } + return r; } -void +int do_where(int argc, const char ** argv) { const char * program; @@ -1183,6 +1292,7 @@ char * endPath; char * fullPath; BOOL found; + int r; found = FALSE; program = argv[1]; @@ -1191,7 +1301,7 @@ { fprintf(stderr, "Program name cannot include a path\n"); - return; + return 1; } path = getenv("PATH"); @@ -1203,7 +1313,7 @@ { fprintf(stderr, "Memory allocation failed\n"); - return; + return 1; } /* @@ -1243,7 +1353,10 @@ if (access(fullPath, X_OK) < 0) { if (errno != ENOENT) - printf("%s: %s\n", fullPath, strerror(errno)); + { + perror(fullPath); + r = 1; + } continue; } @@ -1253,7 +1366,11 @@ } if (!found) + { printf("Program \"%s\" not found in PATH\n", program); + r = 1; + } + return r; } /* END CODE */ Index: sash-3.7/sash.h =================================================================== --- sash-3.7.orig/sash.h 2010-04-04 11:45:33.888951646 +0200 +++ sash-3.7/sash.h 2010-04-04 11:46:22.112949938 +0200 @@ -58,56 +58,56 @@ /* * Built-in command functions. */ -extern void do_alias(int argc, const char ** argv); -extern void do_aliasall(int argc, const char ** argv); -extern void do_cd(int argc, const char ** argv); -extern void do_exec(int argc, const char ** argv); -extern void do_exit(int argc, const char ** argv); -extern void do_prompt(int argc, const char ** argv); -extern void do_source(int argc, const char ** argv); -extern void do_umask(int argc, const char ** argv); -extern void do_unalias(int argc, const char ** argv); -extern void do_help(int argc, const char ** argv); -extern void do_ln(int argc, const char ** argv); -extern void do_cp(int argc, const char ** argv); -extern void do_mv(int argc, const char ** argv); -extern void do_rm(int argc, const char ** argv); -extern void do_chmod(int argc, const char ** argv); -extern void do_mkdir(int argc, const char ** argv); -extern void do_rmdir(int argc, const char ** argv); -extern void do_mknod(int argc, const char ** argv); -extern void do_chown(int argc, const char ** argv); -extern void do_chgrp(int argc, const char ** argv); -extern void do_sum(int argc, const char ** argv); -extern void do_sync(int argc, const char ** argv); -extern void do_printenv(int argc, const char ** argv); -extern void do_more(int argc, const char ** argv); -extern void do_cmp(int argc, const char ** argv); -extern void do_touch(int argc, const char ** argv); -extern void do_ls(int argc, const char ** argv); -extern void do_dd(int argc, const char ** argv); -extern void do_tar(int argc, const char ** argv); -extern void do_ar(int argc, const char ** argv); -extern void do_mount(int argc, const char ** argv); -extern void do_umount(int argc, const char ** argv); -extern void do_setenv(int argc, const char ** argv); -extern void do_pwd(int argc, const char ** argv); -extern void do_echo(int argc, const char ** argv); -extern void do_kill(int argc, const char ** argv); -extern void do_grep(int argc, const char ** argv); -extern void do_file(int argc, const char ** argv); -extern void do_find(int argc, const char ** argv); -extern void do_ed(int argc, const char ** argv); -extern void do_where(int argc, const char ** argv); +extern int do_alias(int argc, const char ** argv); +extern int do_aliasall(int argc, const char ** argv); +extern int do_cd(int argc, const char ** argv); +extern int do_exec(int argc, const char ** argv); +extern int do_exit(int argc, const char ** argv); +extern int do_prompt(int argc, const char ** argv); +extern int do_source(int argc, const char ** argv); +extern int do_umask(int argc, const char ** argv); +extern int do_unalias(int argc, const char ** argv); +extern int do_help(int argc, const char ** argv); +extern int do_ln(int argc, const char ** argv); +extern int do_cp(int argc, const char ** argv); +extern int do_mv(int argc, const char ** argv); +extern int do_rm(int argc, const char ** argv); +extern int do_chmod(int argc, const char ** argv); +extern int do_mkdir(int argc, const char ** argv); +extern int do_rmdir(int argc, const char ** argv); +extern int do_mknod(int argc, const char ** argv); +extern int do_chown(int argc, const char ** argv); +extern int do_chgrp(int argc, const char ** argv); +extern int do_sum(int argc, const char ** argv); +extern int do_sync(int argc, const char ** argv); +extern int do_printenv(int argc, const char ** argv); +extern int do_more(int argc, const char ** argv); +extern int do_cmp(int argc, const char ** argv); +extern int do_touch(int argc, const char ** argv); +extern int do_ls(int argc, const char ** argv); +extern int do_dd(int argc, const char ** argv); +extern int do_tar(int argc, const char ** argv); +extern int do_ar(int argc, const char ** argv); +extern int do_mount(int argc, const char ** argv); +extern int do_umount(int argc, const char ** argv); +extern int do_setenv(int argc, const char ** argv); +extern int do_pwd(int argc, const char ** argv); +extern int do_echo(int argc, const char ** argv); +extern int do_kill(int argc, const char ** argv); +extern int do_grep(int argc, const char ** argv); +extern int do_file(int argc, const char ** argv); +extern int do_find(int argc, const char ** argv); +extern int do_ed(int argc, const char ** argv); +extern int do_where(int argc, const char ** argv); #if HAVE_GZIP -extern void do_gzip(int argc, const char ** argv); -extern void do_gunzip(int argc, const char ** argv); +extern int do_gzip(int argc, const char ** argv); +extern int do_gunzip(int argc, const char ** argv); #endif #if HAVE_LINUX_ATTR -extern void do_lsattr(int argc, const char ** argv); -extern void do_chattr(int argc, const char ** argv); +extern int do_lsattr(int argc, const char ** argv); +extern int do_chattr(int argc, const char ** argv); #endif Index: sash-3.7/sash.c =================================================================== --- sash-3.7.orig/sash.c 2010-04-04 11:45:33.876960339 +0200 +++ sash-3.7/sash.c 2010-04-04 11:46:22.116952745 +0200 @@ -31,7 +31,7 @@ typedef struct { const char * name; - void (*func)(int argc, const char ** argv); + int (*func)(int argc, const char ** argv); int minArgs; int maxArgs; const char * description; @@ -375,10 +375,10 @@ */ static void catchInt(int); static void catchQuit(int); -static void readFile(const char * name); -static void command(const char * cmd); -static BOOL tryBuiltIn(const char * cmd); -static void runCmd(const char * cmd); +static int readFile(const char * name); +static int command(const char * cmd); +static int tryBuiltIn(const char * cmd); +static int runCmd(const char * cmd); static void childProcess(const char * cmd); static void showPrompt(void); static void usage(void); @@ -571,19 +571,20 @@ * Read commands from the specified file. * A null name pointer indicates to read from stdin. */ -static void +static int readFile(const char * name) { FILE * fp; int cc; BOOL ttyFlag; char buf[CMD_LEN]; + int r = 0; if (sourceCount >= MAX_SOURCE) { fprintf(stderr, "Too many source files\n"); - return; + return 1; } fp = stdin; @@ -596,7 +597,7 @@ { perror(name); - return; + return 1; } } @@ -614,7 +615,7 @@ fclose(fp); sourceCount--; - return; + return 1; } if (fgets(buf, CMD_LEN - 1, fp) == NULL) @@ -639,7 +640,7 @@ buf[cc] = '\0'; - command(buf); + r = command(buf); } if (ferror(fp)) @@ -656,6 +657,7 @@ fclose(fp); sourceCount--; + return r; } @@ -664,13 +666,14 @@ * This breaks the command line up into words, checks to see if the * command is an alias, and expands wildcards. */ -static void +static int command(const char * cmd) { const char * endCmd; const Alias * alias; char newCommand[CMD_LEN]; char cmdName[CMD_LEN]; + int r = -1; /* * Rest the interrupt flag and free any memory chunks that @@ -690,7 +693,7 @@ * If the command is empty or is a comment then ignore it. */ if ((*cmd == '\0') || (*cmd == '#')) - return; + return 0; /* * Look for the end of the command name and then copy the @@ -725,14 +728,15 @@ * Now look for the command in the builtin table, and execute * the command if found. */ - if (tryBuiltIn(cmd)) - return; + r = tryBuiltIn(cmd); + if (r >= 0) + return r; /* * The command is not a built-in, so run the program along * the PATH list. */ - runCmd(cmd); + return runCmd(cmd); } @@ -741,7 +745,7 @@ * Returns TRUE if the command is a built in, whether or not the * command succeeds. Returns FALSE if this is not a built-in command. */ -static BOOL +static int tryBuiltIn(const char * cmd) { const char * endCmd; @@ -776,14 +780,14 @@ * If the command is not a built-in, return indicating that. */ if (entry->name == NULL) - return FALSE; + return -1; /* * The command is a built-in. * Break the command up into arguments and expand wildcards. */ if (!makeArgs(cmd, &argc, &argv)) - return TRUE; + return 0; /* * Give a usage string if the number of arguments is too large @@ -793,15 +797,13 @@ { fprintf(stderr, "usage: %s %s\n", entry->name, entry->usage); - return TRUE; + return 0; } /* * Call the built-in function with the argument list. */ - entry->func(argc, argv); - - return TRUE; + return entry->func(argc, argv); } @@ -809,7 +811,7 @@ * Execute the specified command either by forking and executing * the program ourself, or else by using the shell. */ -static void +static int runCmd(const char * cmd) { const char * cp; @@ -854,9 +856,7 @@ */ if (magic) { - system(cmd); - - return; + return system(cmd); } /* @@ -869,7 +869,7 @@ { perror("fork failed"); - return; + return -1; } /* @@ -894,7 +894,7 @@ { fprintf(stderr, "Error from waitpid: %s", strerror(errno)); - return; + return -1; } if (WIFSIGNALED(status)) @@ -902,6 +902,7 @@ fprintf(stderr, "pid %ld: killed by signal %d\n", (long) pid, WTERMSIG(status)); } + return WEXITSTATUS(status); } @@ -958,7 +959,7 @@ } -void +int do_help(int argc, const char ** argv) { const CommandEntry * entry; @@ -983,7 +984,7 @@ printf("usage: %s %s\n", entry->name, entry->usage); - return; + return 0; } } } @@ -1000,10 +1001,11 @@ printf("%-10s %s\n", entry->name, entry->usage); } } + return 0; } -void +int do_alias(int argc, const char ** argv) { const char * name; @@ -1019,7 +1021,7 @@ for (alias = aliasTable; count-- > 0; alias++) printf("%s\t%s\n", alias->name, alias->value); - return; + return 0; } name = argv[1]; @@ -1029,22 +1031,26 @@ alias = findAlias(name); if (alias) + { printf("%s\n", alias->value); + return 0; + } else + { fprintf(stderr, "Alias \"%s\" is not defined\n", name); - - return; + return 1; + } } if (strcmp(name, "alias") == 0) { fprintf(stderr, "Cannot alias \"alias\"\n"); - return; + return 1; } if (!makeString(argc - 2, argv + 2, buf, CMD_LEN)) - return; + return -1; value = malloc(strlen(buf) + 1); @@ -1052,7 +1058,7 @@ { fprintf(stderr, "No memory for alias value\n"); - return; + return 1; } strcpy(value, buf); @@ -1064,7 +1070,7 @@ free(alias->value); alias->value = value; - return; + return 0; } if ((aliasCount % ALIAS_ALLOC) == 0) @@ -1084,7 +1090,7 @@ free(value); fprintf(stderr, "No memory for alias table\n"); - return; + return 1; } aliasTable = alias; @@ -1099,12 +1105,13 @@ free(value); fprintf(stderr, "No memory for alias name\n"); - return; + return 1; } strcpy(alias->name, name); alias->value = value; aliasCount++; + return 0; } @@ -1112,12 +1119,13 @@ * Build aliases for all of the built-in commands which start with a dash, * using the names without the dash. */ -void +int do_aliasall(int argc, const char **argv) { const CommandEntry * entry; const char * name; const char * newArgv[4]; + int r; for (entry = commandEntryTable; entry->name; entry++) { @@ -1131,8 +1139,13 @@ newArgv[2] = name; newArgv[3] = NULL; - do_alias(3, newArgv); + r = do_alias(3, newArgv); + if (r != 0) + { + return r; + } } + return 0; } @@ -1158,14 +1171,14 @@ } -void +int do_source(int argc, const char ** argv) { - readFile(argv[1]); + return readFile(argv[1]); } -void +int do_exec(int argc, const char ** argv) { const char * name; @@ -1182,17 +1195,18 @@ execvp(name, (char **) argv + 1); perror(name); + return 127; } -void +int do_prompt(int argc, const char ** argv) { char * cp; char buf[CMD_LEN]; if (!makeString(argc - 1, argv + 1, buf, CMD_LEN)) - return; + return 1; cp = malloc(strlen(buf) + 2); @@ -1200,7 +1214,7 @@ { fprintf(stderr, "No memory for prompt\n"); - return; + return 1; } strcpy(cp, buf); @@ -1210,10 +1224,11 @@ free(prompt); prompt = cp; + return 0; } -void +int do_unalias(int argc, const char ** argv) { Alias * alias; @@ -1231,6 +1246,7 @@ alias->name = aliasTable[aliasCount].name; alias->value = aliasTable[aliasCount].value; } + return 0; } Index: sash-3.7/cmd_dd.c =================================================================== --- sash-3.7.orig/cmd_dd.c 2010-04-04 12:29:35.236953933 +0200 +++ sash-3.7/cmd_dd.c 2010-04-04 12:32:57.081955729 +0200 @@ -40,7 +40,7 @@ static long getNum(const char * cp); -void +int do_dd(int argc, const char ** argv) { const char * str; @@ -62,6 +62,7 @@ long outPartial; char * buf; char localBuf[BUF_SIZE]; + int r; inFile = NULL; outFile = NULL; @@ -69,6 +70,7 @@ skipVal = 0; blockSize = 512; count = -1; + r = 0; while (--argc > 0) { @@ -79,7 +81,7 @@ { fprintf(stderr, "Bad dd argument\n"); - return; + return 1; } *cp++ = '\0'; @@ -97,7 +99,7 @@ { fprintf(stderr, "Multiple input files illegal\n"); - return; + return 1; } inFile = cp; @@ -108,7 +110,7 @@ { fprintf(stderr, "Multiple output files illegal\n"); - return; + return 1; } outFile = cp; @@ -121,7 +123,7 @@ { fprintf(stderr, "Bad block size value\n"); - return; + return 1; } break; @@ -133,7 +135,7 @@ { fprintf(stderr, "Bad count value\n"); - return; + return 1; } break; @@ -145,7 +147,7 @@ { fprintf(stderr, "Bad seek value\n"); - return; + return 1; } break; @@ -157,7 +159,7 @@ { fprintf(stderr, "Bad skip value\n"); - return; + return 1; } break; @@ -165,7 +167,7 @@ default: fprintf(stderr, "Unknown dd parameter\n"); - return; + return 1; } } @@ -173,14 +175,14 @@ { fprintf(stderr, "No input file specified\n"); - return; + return 1; } if (outFile == NULL) { fprintf(stderr, "No output file specified\n"); - return; + return 1; } buf = localBuf; @@ -193,7 +195,7 @@ { fprintf(stderr, "Cannot allocate buffer\n"); - return; + return 1; } } @@ -211,7 +213,7 @@ if (buf != localBuf) free(buf); - return; + return 1; } outFd = creat(outFile, 0666); @@ -224,7 +226,7 @@ if (buf != localBuf) free(buf); - return; + return 1; } if (skipVal) @@ -238,12 +240,14 @@ if (inCc < 0) { perror(inFile); + r = 1; goto cleanup; } if (inCc == 0) { fprintf(stderr, "End of file while skipping\n"); + r = 1; goto cleanup; } } @@ -255,7 +259,7 @@ if (lseek(outFd, seekVal * blockSize, 0) < 0) { perror(outFile); - + r = 1; goto cleanup; } } @@ -274,6 +278,7 @@ if (intFlag) { fprintf(stderr, "Interrupted\n"); + r = 1; goto cleanup; } @@ -284,6 +289,7 @@ if (outCc < 0) { perror(outFile); + r = 1; goto cleanup; } @@ -303,7 +309,10 @@ close(inFd); if (close(outFd) < 0) + { perror(outFile); + r = 1; + } if (buf != localBuf) free(buf); @@ -311,6 +320,7 @@ printf("%ld+%ld records in\n", inFull, inPartial); printf("%ld+%ld records out\n", outFull, outPartial); + return r; } Index: sash-3.7/cmd_ed.c =================================================================== --- sash-3.7.orig/cmd_ed.c 2010-04-04 12:33:11.076954419 +0200 +++ sash-3.7/cmd_ed.c 2010-04-04 12:34:01.244953056 +0200 @@ -60,11 +60,11 @@ (const LINE * lp, const char * str, LEN len, LEN offset); -void +int do_ed(int argc, const char ** argv) { if (!initEdit()) - return; + return 1; if (argc > 1) { @@ -75,14 +75,14 @@ fprintf(stderr, "No memory\n"); termEdit(); - return; + return 1; } if (!readLines(fileName, 1)) { termEdit(); - return; + return 1; } if (lastNum) @@ -94,6 +94,7 @@ doCommands(); termEdit(); + return 0; } Index: sash-3.7/cmd_grep.c =================================================================== --- sash-3.7.orig/cmd_grep.c 2010-04-04 12:34:30.320951181 +0200 +++ sash-3.7/cmd_grep.c 2010-04-04 12:38:36.524986801 +0200 @@ -15,7 +15,7 @@ (const char * string, const char * word, BOOL ignoreCase); -void +int do_grep(int argc, const char ** argv) { FILE * fp; @@ -27,7 +27,9 @@ BOOL tellLine; long line; char buf[BUF_SIZE]; + int r; + r = 1; ignoreCase = FALSE; tellLine = FALSE; @@ -52,7 +54,7 @@ default: fprintf(stderr, "Unknown option\n"); - return; + return 1; } } @@ -70,6 +72,7 @@ if (fp == NULL) { perror(name); + r = 1; continue; } @@ -82,7 +85,7 @@ { fclose(fp); - return; + return 1; } line++; @@ -94,6 +97,7 @@ if (search(buf, word, ignoreCase)) { + r = 0; if (tellName) printf("%s: ", name); @@ -109,6 +113,7 @@ fclose(fp); } + return r; } Index: sash-3.7/cmd_ls.c =================================================================== --- sash-3.7.orig/cmd_ls.c 2010-04-04 12:38:46.364975686 +0200 +++ sash-3.7/cmd_ls.c 2010-04-04 12:40:32.424951492 +0200 @@ -59,7 +59,7 @@ static void clearListNames(void); -void +int do_ls(int argc, const char ** argv) { const char * cp; @@ -72,6 +72,7 @@ struct dirent * dp; char fullName[PATH_LEN]; struct stat statBuf; + int r; static const char * def[] = {"."}; @@ -105,7 +106,7 @@ default: fprintf(stderr, "Unknown option -%c\n", cp[-1]); - return; + return 1; } } @@ -153,7 +154,7 @@ if ((flags & LSF_DIR) || !isDirectory(argv[i])) { if (!addListName(argv[i])) - return; + return 1; } } @@ -167,7 +168,7 @@ * If directories were being listed as themselves, then we are done. */ if (flags & LSF_DIR) - return; + return r; /* * Now iterate over the file names processing the directories. @@ -180,6 +181,7 @@ if (LSTAT(name, &statBuf) < 0) { perror(name); + r = 1; continue; } @@ -226,7 +228,7 @@ { closedir(dirp); - return; + return 1; } } @@ -239,6 +241,7 @@ listAllFiles(flags, displayWidth); clearListNames(); } + return r; } Index: sash-3.7/cmd_tar.c =================================================================== --- sash-3.7.orig/cmd_tar.c 2010-04-04 12:40:41.588964080 +0200 +++ sash-3.7/cmd_tar.c 2010-04-04 12:41:56.960954363 +0200 @@ -119,7 +119,7 @@ -void +int do_tar(int argc, const char ** argv) { const char * options; @@ -131,7 +131,7 @@ { fprintf(stderr, "Too few arguments for tar\n"); - return; + return 1; } extractFlag = FALSE; @@ -158,7 +158,7 @@ { fprintf(stderr, "Only one 'f' option allowed\n"); - return; + return 1; } tarName = *argv++; @@ -185,7 +185,7 @@ default: fprintf(stderr, "Unknown tar flag '%c'\n", *options); - return; + return 1; } } @@ -196,14 +196,14 @@ { fprintf(stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); - return; + return 1; } if (tarName == NULL) { fprintf(stderr, "The 'f' flag must be specified\n"); - return; + return 1; } /* @@ -211,9 +211,9 @@ * command line arguments as the list of files to process. */ if (createFlag) - writeTarFile(argc, argv); + return writeTarFile(argc, argv); else - readTarFile(argc, argv); + return readTarFile(argc, argv); } @@ -221,7 +221,7 @@ * Read a tar file and extract or list the specified files within it. * If the list is empty than all files are extracted or listed. */ -static void +static int readTarFile(int fileCount, const char ** fileTable) { const char * cp; @@ -250,7 +250,7 @@ { perror(tarName); - return; + return 1; } /* debian/patches/exit_with_argument0000644000000000000000000000163211740504131014444 0ustar Subject: Let exit have an optional argument From: Tollef Fog Heen Last-updated: 2010-04-04 Index: sash-3.7/cmds.c =================================================================== --- sash-3.7.orig/cmds.c 2002-07-22 00:28:19.000000000 +0200 +++ sash-3.7/cmds.c 2010-04-04 10:58:51.604971262 +0200 @@ -993,14 +993,18 @@ void do_exit(int argc, const char ** argv) { + int r = 0; if (getpid() == 1) { fprintf(stderr, "You are the INIT process!\n"); return; } - - exit(0); + if (argc == 2) + { + r = atoi(argv[1]); + } + exit(r); } Index: sash-3.7/sash.c =================================================================== --- sash-3.7.orig/sash.c 2004-01-14 06:08:03.000000000 +0100 +++ sash-3.7/sash.c 2010-04-04 10:58:51.604971262 +0200 @@ -132,9 +132,9 @@ }, { - "exit", do_exit, 1, 1, + "exit", do_exit, 1, 2, "Exit from sash", - "" + "[exit value]" }, { debian/patches/e2fslibs_chattr_include0000644000000000000000000000101011740504131015305 0ustar Subject: Use includes from e2fslibs rather than the kernel From: Tollef Fog Heen Bug-Debian: #223203 Last-updated: 2010-04-04 Index: sash-3.7/cmd_chattr.c =================================================================== --- sash-3.7.orig/cmd_chattr.c 2010-04-04 10:40:52.644957438 +0200 +++ sash-3.7/cmd_chattr.c 2010-04-04 10:41:11.084974379 +0200 @@ -12,7 +12,7 @@ #include #include -#include +#include #include "sash.h" debian/patches/touch_error_handling0000644000000000000000000000107611740504131014737 0ustar Subject: Correct error message when touching non-existent file in non-writeable directory From: Tollef Fog Heen , Raul Miller Bug-Debian: #43428 Last-updated: 2010-04-04 Index: sash-3.7/cmds.c =================================================================== --- sash-3.7.orig/cmds.c 2010-04-04 10:58:51.000000000 +0200 +++ sash-3.7/cmds.c 2010-04-04 11:04:55.185955708 +0200 @@ -341,6 +341,11 @@ continue; } + if (errno != EEXIST) { + perror(name); + continue; + } + if (utime(name, &now) < 0) perror(name); } debian/patches/interactive_flag0000644000000000000000000000343011740504131014042 0ustar Subject: Add -i option From: Michael Meskes Bug-Debian: #19656 Last-updated: 2010-04-04 Index: sash-3.7/sash.c =================================================================== --- sash-3.7.orig/sash.c 2010-04-04 10:35:51.268950839 +0200 +++ sash-3.7/sash.c 2010-04-04 10:36:42.572973204 +0200 @@ -399,12 +399,14 @@ const char * commandFile; BOOL quietFlag; BOOL aliasFlag; + BOOL interactiveFlag; char buf[PATH_LEN]; singleCommand = NULL; commandFile = NULL; quietFlag = FALSE; aliasFlag = FALSE; + interactiveFlag = FALSE; /* * Look for options. @@ -419,11 +421,17 @@ while (*cp) switch (*cp++) { + case '-': + /* + * Ignore. This is so that we can be + * run from login. + */ + break; case 'c': /* * Execute specified command. */ - if ((argc != 1) || singleCommand) + if ((argc != 1) || singleCommand || interactiveFlag) usage(); singleCommand = *argv++; @@ -446,6 +454,18 @@ break; + case 'i': + /* + * Be an interactive shell + * ..is a no-op, but some contexts require this + * ..interactiveFlag is to avoid -ic as a legacy + */ + if (singleCommand) + usage(); + + interactiveFlag = TRUE; + break; + case 'p': /* * Set the prompt string. @@ -1263,7 +1290,7 @@ { fprintf(stderr, "Stand-alone shell (version %s)\n", version); fprintf(stderr, "\n"); - fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt]\n"); + fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt] [-i]\n"); exit(1); } debian/patches/fix_exec0000644000000000000000000000114511740504131012327 0ustar Subject: Don't check permissions before trying to execute a command From: Unknown Last-updated: 2010-04-04 Index: sash-3.7/sash.c =================================================================== --- sash-3.7.orig/sash.c 2010-04-04 10:12:57.228978742 +0200 +++ sash-3.7/sash.c 2010-04-04 10:13:04.008985124 +0200 @@ -1172,13 +1172,6 @@ name = argv[1]; - if (access(name, 4)) - { - perror(name); - - return; - } - while (--sourceCount >= 0) { if (sourcefiles[sourceCount] != stdin) @@ -1188,7 +1181,7 @@ argv[argc] = NULL; execvp(name, (char **) argv + 1); - exit(1); + perror(name); } debian/patches/exit_with_command_status0000644000000000000000000000614211740504131015644 0ustar Index: sash-3.7/sash.c =================================================================== --- sash-3.7.orig/sash.c 2010-04-04 14:56:47.964954627 +0200 +++ sash-3.7/sash.c 2010-04-04 14:57:03.932954934 +0200 @@ -375,10 +375,10 @@ */ static void catchInt(int); static void catchQuit(int); -static void readFile(const char * name); -static void command(const char * cmd); +static int readFile(const char * name); +static int command(const char * cmd); static BOOL tryBuiltIn(const char * cmd); -static void runCmd(const char * cmd); +static int runCmd(const char * cmd); static void childProcess(const char * cmd); static void showPrompt(void); static void usage(void); @@ -524,9 +524,7 @@ */ if (singleCommand) { - command(singleCommand); - - return 0; + return command(singleCommand); } /* @@ -561,9 +559,8 @@ /* * Read commands from stdin or from a command file. */ - readFile(commandFile); + return readFile(commandFile); - return 0; } @@ -571,19 +568,20 @@ * Read commands from the specified file. * A null name pointer indicates to read from stdin. */ -static void +static int readFile(const char * name) { FILE * fp; int cc; BOOL ttyFlag; char buf[CMD_LEN]; + int r = 0; if (sourceCount >= MAX_SOURCE) { fprintf(stderr, "Too many source files\n"); - return; + return 1; } fp = stdin; @@ -596,7 +594,7 @@ { perror(name); - return; + return 1; } } @@ -614,7 +612,7 @@ fclose(fp); sourceCount--; - return; + return 1; } if (fgets(buf, CMD_LEN - 1, fp) == NULL) @@ -639,7 +637,7 @@ buf[cc] = '\0'; - command(buf); + r = command(buf); } if (ferror(fp)) @@ -656,6 +654,7 @@ fclose(fp); sourceCount--; + return r; } @@ -664,7 +663,7 @@ * This breaks the command line up into words, checks to see if the * command is an alias, and expands wildcards. */ -static void +static int command(const char * cmd) { const char * endCmd; @@ -690,7 +689,7 @@ * If the command is empty or is a comment then ignore it. */ if ((*cmd == '\0') || (*cmd == '#')) - return; + return 0; /* * Look for the end of the command name and then copy the @@ -726,13 +725,13 @@ * the command if found. */ if (tryBuiltIn(cmd)) - return; + return 0; /* This is a blatant lie */ /* * The command is not a built-in, so run the program along * the PATH list. */ - runCmd(cmd); + return runCmd(cmd); } @@ -809,7 +808,7 @@ * Execute the specified command either by forking and executing * the program ourself, or else by using the shell. */ -static void +static int runCmd(const char * cmd) { const char * cp; @@ -854,9 +853,7 @@ */ if (magic) { - system(cmd); - - return; + return system(cmd); } /* @@ -869,7 +866,7 @@ { perror("fork failed"); - return; + return -1; } /* @@ -894,7 +891,7 @@ { fprintf(stderr, "Error from waitpid: %s", strerror(errno)); - return; + return -1; } if (WIFSIGNALED(status)) @@ -902,6 +899,7 @@ fprintf(stderr, "pid %ld: killed by signal %d\n", (long) pid, WTERMSIG(status)); } + return WEXITSTATUS(status); } debian/patches/freebsd_build0000644000000000000000000000351311740510070013326 0ustar Subject: Build fixes for Debian GNU/kFreeBSD From: Axel Beckert Bug-Debian: #565539 Last-updated: 2010-04-04 Index: sash-3.7/Makefile =================================================================== --- sash-3.7.orig/Makefile 2010-04-04 11:13:36.005953632 +0200 +++ sash-3.7/Makefile 2010-04-04 11:38:19.300955689 +0200 @@ -9,9 +9,17 @@ # HAVE_GZIP = 1 +ifeq (Linux,$(shell uname -s)) HAVE_LINUX_ATTR = 1 HAVE_LINUX_MOUNT = 1 HAVE_BSD_MOUNT = 0 MOUNT_TYPE = '"ext3"' +endif +ifeq (GNU/kFreeBSD,$(shell uname -s)) +HAVE_LINUX_ATTR = 0 +HAVE_LINUX_MOUNT = 0 +HAVE_BSD_MOUNT = 1 +MOUNT_TYPE = '"ufs"' +endif DEFS = -DHAVE_GZIP=$(HAVE_GZIP) \ -DHAVE_LINUX_ATTR=$(HAVE_LINUX_ATTR) \ Index: sash-3.7/cmds.c =================================================================== --- sash-3.7.orig/cmds.c 2010-04-04 11:13:36.025952857 +0200 +++ sash-3.7/cmds.c 2010-04-04 11:37:59.160966064 +0200 @@ -19,6 +19,10 @@ #if HAVE_LINUX_MOUNT #include +#elif HAVE_BSD_MOUNT +#include +#include +#include #endif @@ -599,26 +603,16 @@ #elif HAVE_BSD_MOUNT { struct ufs_args ufs; - struct adosfs_args adosfs; struct iso_args iso; - struct mfs_args mfs; struct msdosfs_args msdosfs; void * args; if(!strcmp(type, "ffs") || !strcmp(type, "ufs")) { ufs.fspec = (char*) argv[0]; args = &ufs; - } else if(!strcmp(type, "adosfs")) { - adosfs.fspec = (char*) argv[0]; - adosfs.uid = 0; - adosfs.gid = 0; - args = &adosfs; } else if(!strcmp(type, "cd9660")) { iso.fspec = (char*) argv[0]; args = &iso; - } else if(!strcmp(type, "mfs")) { - mfs.fspec = (char*) argv[0]; - args = &mfs; } else if(!strcmp(type, "msdos")) { msdosfs.fspec = (char*) argv[0]; msdosfs.uid = 0; debian/patches/series0000644000000000000000000000021511740506370012033 0ustar exit_with_argument e2fslibs_chattr_include touch_error_handling interactive_flag fix_exec buildsystem freebsd_build exit_with_command_status debian/lintian-overrides0000644000000000000000000000011611740517331012547 0ustar sash: statically-linked-binary bin/sash sash: embedded-library bin/sash: zlib debian/changelog0000644000000000000000000003173712222102716011046 0ustar sash (3.7-13) unstable; urgency=low * Update to debhelper compat version 9, which adds hardening. * Update to newer Standards-Version, add Built-Using field. -- Tollef Fog Heen Sun, 29 Sep 2013 16:11:22 +0200 sash (3.7-12) unstable; urgency=low * Update lintian overrides for new names. -- Tollef Fog Heen Mon, 09 Apr 2012 10:34:04 +0200 sash (3.7-11) unstable; urgency=low * Update to dh version 8 * Add dh_buildflags support, closes: #654909 * Update FreeBSD build patch. Closes: #565539 -- Tollef Fog Heen Mon, 09 Apr 2012 09:11:01 +0200 sash (3.7-10) unstable; urgency=low * Switch to 3.0 (quilt) as the source format and convert patches. * Fix up debian/patches/touch_error_handling to actually update the timestamp of the file, something that has been broken for more than ten years. * Add kFreeBSD build fixes from Axel Beckert. Closes: #565539 * When exiting the shell, use the exit status of the last command as our exit status. Closes: #281728 -- Tollef Fog Heen Sun, 04 Apr 2010 10:25:57 +0200 sash (3.7-9) unstable; urgency=low * Drop dependency on lockfile-progs, no longer needed. * Drop versioned dependency on passwd, that version is pre-oldstable * Drop versioned conflicts on fileutils, that version is pre-oldstable. * Move to debhelper 7 instead of cdbs. * Add missing set -e to postrm. * Drop full paths to add-shell and remove-shell. * Add lintian override for embedded zlib. -- Tollef Fog Heen Fri, 09 Oct 2009 09:15:48 +0200 sash (3.7-8) unstable; urgency=medium * Get rid of the sashroot account and all debconfiscation (but don't change already-set up systems). Closes: #410758, #400892, #482900, #489380 * Unconditionally remove sashroot when removing the package. Closes: #464610 * Call add-shell when upgrading from etch or older. Closes: #416059. * Remove -s from LDFLAGS. Closes: #437952 * Stop setting PATH in postinst. * Update to newest policy version - Add Homepage field. -- Tollef Fog Heen Mon, 21 Jul 2008 13:45:15 +0200 sash (3.7-7.3) unstable; urgency=low * Non-maintainer upload to fix pending l10n issues * Debconf translations: - Dutch. Closes: #414751 - Spanish. Closes: #415201 - French converted to UTF-8 - Finnish. Closes: #472616 - Basque. Closes: #475359 - Galician. Closes: #475462 * [Lintian] Change menu entry to Applications/Shells * Upgrade Standards from 3.6.1 to 3.7.3 (checked) -- Christian Perrier Tue, 25 Mar 2008 18:23:28 +0100 sash (3.7-7.2) unstable; urgency=low * NMU * Apparently CDBS decided to start overwriting the LDFLAGS setting, which made sash no longer statically linked. Work around this brain-damage. Closes: #403659 -- Joey Hess Tue, 19 Dec 2006 18:16:21 -0500 sash (3.7-7.1) unstable; urgency=low * Non-maintainer upload to fix longstanding l10n issues * Rewrite templates to better fit the Developer's Reference recommendations This also Closes: #368750 * Debconf translation updates: - Swedish added. Closes: #338776 - French updated. Sent during the call for updates of the NMU campaign. - Vietnamese updated. Sent during the call for updates of the NMU campaign. - Dzongkha added. Sent during the call for updates of the NMU campaign. - German added. Sent during the call for updates of the NMU campaign. - Russian added. Sent during the call for updates of the NMU campaign. -- Christian Perrier Wed, 29 Nov 2006 07:40:31 +0100 sash (3.7-7) unstable; urgency=low * Remove /usr/doc/sash symlink if it exists. (closes: #322797) * Fix up debconf dependency, we want debconf | debconf-2.0 -- Tollef Fog Heen Thu, 1 Sep 2005 07:52:20 +0200 sash (3.7-6) unstable; urgency=high * Tighten zlib build-deps to fix security issue (closes: #318069) * Add Czech debconf translation (closes: #294777) * Add Vietnamese debconf translation (closes: #317886) -- Tollef Fog Heen Thu, 14 Jul 2005 12:33:51 +0200 sash (3.7-5) unstable; urgency=low * Add Japanese debconf translation (closes: #290129) * Add German debconf translation (closes: #266357) -- Tollef Fog Heen Sat, 5 Feb 2005 12:57:59 +0100 sash (3.7-4) unstable; urgency=low * Add French debconf translation (closes: #232979) * Add lintian override (closes: #235306) -- Tollef Fog Heen Thu, 1 Apr 2004 03:42:48 +0200 sash (3.7-3) unstable; urgency=low * Use po-debconf. -- Tollef Fog Heen Tue, 10 Feb 2004 03:12:41 +0100 sash (3.7-2) unstable; urgency=low * Fix versioned depends on passwd. (closes: #229192) -- Tollef Fog Heen Fri, 23 Jan 2004 17:57:59 +0100 sash (3.7-1) unstable; urgency=low * New upstream release - Fixes (closes: #227164) * Only ask about deleting sashroot account if it's actually created. (closes: #225341) * Ask about removing sashroot user in prerm instead of when installing. (closes: #227637) -- Tollef Fog Heen Tue, 13 Jan 2004 00:41:55 +0100 sash (3.6-5) unstable; urgency=low * Remove -m call to useradd. (closes: #225093) * Up standards-version. -- Tollef Fog Heen Fri, 26 Dec 2003 22:57:29 +0100 sash (3.6-4) unstable; urgency=medium * Use chown root:shadow instead of root.shadow in sashconfig (closes: #217395) * Depend on passwd (>= 20000902-12) (closes: #219961) * Use debconf. (closes: #86208, #96566) - Thereby getting rid of sashconfig. Yay. * Build-dep on e2fslibs-dev, since it seems like libc6 broke us. (closes: #223203) -- Tollef Fog Heen Wed, 17 Dec 2003 23:00:13 +0100 sash (3.6-3) unstable; urgency=low * .. and add build-deps for debhelper (closes: #216746) -- Tollef Fog Heen Tue, 21 Oct 2003 21:19:54 +0200 sash (3.6-2) unstable; urgency=low * Add build-deps for cdbs (closes: #216499) -- Tollef Fog Heen Sun, 19 Oct 2003 12:16:43 +0200 sash (3.6-1) unstable; urgency=low * Adopt package (closes: #215544) * New upstream release * Ack NMUs, (closes: #137947, #117065, #91634, #109027, #170081, #125332) * Redo packaging using CDBS. * Remove obsolete emacs vars in changelog. * Ignore -- in option list (closes: #95374) -- Tollef Fog Heen Fri, 17 Oct 2003 13:17:02 +0200 sash (3.4-8.3) unstable; urgency=low * NMU * Trivial bugfix for #125332 (Closes: #125332) * debian/rules: must call dpkg-genchanges with -isp, otherwise it won't get into the binary package control files. (Closes: #170081) -- Hwei Sheng Teoh Thu, 21 Nov 2002 13:38:31 -0500 sash (3.4-8.2) unstable; urgency=low * Non-maintainer upload. * debian/control: Build-depend on a version of zlib without the double-free bug (closes: #137947). -- Colin Watson Sun, 17 Mar 2002 13:58:46 +0000 sash (3.4-8.1) unstable; urgency=low * NMU * Make unstable have at least the same rev as stable. Changelog change only. -- LaMont Jones Thu, 25 Oct 2001 09:42:55 -0600 sash (3.4-8) stable; urgency=low * control file cleanup -- Raul Miller Mon, 21 May 2001 10:42:50 -0400 sash (3.4-7) stable; urgency=low * incorporated workaround for dpkg breakage on /usr/doc -> /usr/share/doc (fixes #91634) * adopted adrian bunk's suggestions for build-depends (fixes #94329) * this version being new, will be newer than that in potato (fixes #97561) * no Section: problem was apparently caused by build tools -- a test build shows that 3.4-7 has Section: shells (fixes #84494) * not fixed: no debconf support yet. I'm still considering legacy issues. * not fixed: support for -- as end of options indicator. Meaningless, as sash takes no non-options arguments (it's not designed for scripts). -- Raul Miller Sat, 19 May 2001 19:36:52 -0400 sash (3.4-6) stable; urgency=medium * incorporated suggestion from Matt Zimmerman such that clone_root_as_sashroot is properly atomic, even for ownership and permissions. -- Raul Miller Wed, 17 Jan 2001 12:47:42 -0500 sash (3.4-5) stable; urgency=medium * fix up /etc/shadow to give group shadow read access -- Raul Miller Tue, 16 Jan 2001 11:47:27 -0500 sash (3.4-4) stable; urgency=high * umask 077 before cloning /etc/shadow (fixes #81793) [ouch] -- Raul Miller Wed, 10 Jan 2001 20:42:15 -0500 sash (3.4-3) unstable; urgency=low * put back /usr/doc/sash if helper programs fail to provide it -- Raul Miller Fri, 15 Oct 1999 18:55:13 -0400 sash (3.4-2) unstable; urgency=low * set permissions on sashconfig from debian/rules (Fixes #47307) -- Raul Miller Wed, 13 Oct 1999 13:16:49 -0400 sash (3.4-1) unstable; urgency=low * new upstream version, adds -ar command for debian * cleaned up handling of Q option in prompts, fixes (#46054, #46820) * rewrote README.debian with some minor hints about usage (fixes #45617) -- Raul Miller Thu, 7 Oct 1999 23:10:19 -0400 sash (3.3-7) unstable; urgency=high * Re-invented sash config system again. This time with a rich set of prompts, and the option to record them so they need be answered only once. (fixes #45617) This reinstates /var/lib/sash/. * Mentioned init=/bin/sash at boot prompt (fixes #45547) * rm -rf /var/lib/sash/ at package purge time (fixes #27770) * make #include conditional in cmds.c -- Raul Miller Thu, 23 Sep 1999 22:13:43 -0400 sash (3.3-6) unstable; urgency=low * rewrote postinst to support NIS (fixes #45467) * removed empty /var/lib/sash/ * use -Os (instead of -O3) for smaller footprint [At the moment, this results in no measurable change -- and most of the footprint is from libc. I'm leaving it in for documentation purposes.] -- Raul Miller Sun, 19 Sep 1999 08:32:29 -0400 sash (3.3-5) unstable; urgency=low * added Depends: lockfile-progs (needed for new postinst/prerm) -- Raul Miller Sun, 19 Sep 1999 01:04:38 -0400 sash (3.3-4) unstable; urgency=low * rebuilt using altgcc (cuts executable size ~44%) -- Raul Miller Fri, 3 Sep 1999 18:51:39 -0400 sash (3.3-3) unstable; urgency=low * removed yet more junk files from diff -- Raul Miller Fri, 3 Sep 1999 18:51:34 -0400 sash (3.3-2) unstable; urgency=low * removed junk file from diff -- Raul Miller Fri, 3 Sep 1999 18:37:33 -0400 sash (3.3-1) unstable; urgency=low * new upstream version * use $(CC) in makefile in place of cc (#31220) * completely rewrote postinst and replaced postrm with new prerm (#27632, #41968) * simplified error handling for failed -touch (#43428) * upgraded to upstream version 3.3 (#39145) -- Raul Miller Fri, 3 Sep 1999 18:03:00 -0400 sash (2.1-5) unstable; urgency=low * New maintainer done properly -- Raul Miller Fri, 3 Sep 1999 18:01:14 -0400 sash (2.1-4) unstable; urgency=low * Use $PATH in exec [#25034] * New maintainer -- Raul Miller Thu, 27 Aug 1998 12:19:33 -0400 sash (2.1-3) frozen unstable; urgency=low * correct root shell if package is removed -- Michael Meskes Fri, 20 Mar 1998 14:11:28 +0100 sash (2.1-2) unstable; urgency=low * Fixed postinst (#19584) * Added -i option (#19656) -- Michael Meskes Mon, 16 Mar 1998 15:23:44 +0100 sash (2.1-1) unstable; urgency=low * New upstream version: David incorporated most of my changes except that he wants sash to print a message everytime it starts. But he has added an option -q to get it quiet. I hope that solves the problem as well. -- Michael Meskes Mon, 9 Mar 1998 13:42:33 +0100 sash (2.0-3) unstable; urgency=low * corrected argv handling for exec call (#18695) * reworked postinst/prerm to make installation ask less questions -- Michael Meskes Fri, 27 Feb 1998 08:57:00 +0100 sash (2.0-2) unstable; urgency=low * sash no longer prints a message every time you invoke it (#18580) -- Michael Meskes Fri, 27 Feb 1998 08:57:00 +0100 sash (2.0-1) unstable; urgency=low * New upstream version -- Michael Meskes Fri, 30 Jan 1998 10:25:59 +0100 sash (1.0-3) unstable; urgency=low * Added -c option which fixes the problem with su as well as bug (#17573). -- Michael Meskes Thu, 29 Jan 1998 09:38:41 +0100 sash (1.0-2) unstable; urgency=low * Added section entry. -- Michael Meskes Tue, 16 Dec 1997 11:05:51 +0100 sash (1.0-1) unstable; urgency=low * Initial Release. -- Michael Meskes Tue, 16 Dec 1997 11:05:51 +0100