Reboot when CTRL+C in mySQL-client build
When updating mysql with portupgrade -a, the computer reboots without a crash dump. (#:/home/eirik)- portupgrade -a ... --- Upgrading 'mysql-client-3.23.53_1' to 'mysql-client-3.23.54' (databases/mysql323-client) ... checking for restartable system calls... ^--- There it just hangs, when I push CTRL+C to skip it, my computer reboots. I get no errors or anything. Will try to debug it some more and give more info if I get it. Uname: FreeBSD odin.eirikn.net 5.0-CURRENT FreeBSD 5.0-CURRENT #22: Sun Jan 12 22:14:59 CET 2003 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/ITvision i386 Last cvsup of ports and src: 9 Janaury, 2003. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE msg50213/pgp0.pgp Description: PGP signature
Re: swapoff code comitted.
On Sun, Dec 15, 2002 at 02:47:51PM -0800, Matthew Dillon wrote: : :How about renaming swapon(8) into swapctl(8) after this function enhancemen= :t? :This name reflects it's purpose much better and would be consistent with the :other BSDs. : :- Christian I am not volunteering to do this, at least not right now. I have too big a stack of things that still need to be committed, but if someone else would like to tackle this I think it would be a nice little project for a developer with some free time to waste and I would be happy to review and test the work. I have made a small patch, added l, s and h switches to show information about the swap devices. And the U switch to swapctl only to remove all activated swap devices. If anything else is needed let me know and I will add it. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE Index: sbin/swapon/Makefile === RCS file: /home/ncvs/src/sbin/swapon/Makefile,v retrieving revision 1.7 diff -u -r1.7 Makefile --- sbin/swapon/Makefile15 Dec 2002 19:17:56 - 1.7 +++ sbin/swapon/Makefile17 Dec 2002 17:00:47 - @@ -3,7 +3,9 @@ PROG= swapon MAN= swapon.8 -LINKS= ${BINDIR}/swapon ${BINDIR}/swapoff +LINKS= ${BINDIR}/swapoff ${BINDIR}/swapon +LINKS+=${BINDIR}/swapctl ${BINDIR}/swapon MLINKS=swapon.8 swapoff.8 +LDADD= -lc -lkvm .include bsd.prog.mk Index: sbin/swapon/swapon.c === RCS file: /home/ncvs/src/sbin/swapon/swapon.c,v retrieving revision 1.13 diff -u -r1.13 swapon.c --- sbin/swapon/swapon.c15 Dec 2002 19:17:56 - 1.13 +++ sbin/swapon/swapon.c17 Dec 2002 17:00:47 - @@ -52,10 +52,17 @@ #include stdlib.h #include string.h #include unistd.h +#include kvm.h +#include fcntl.h -static void usage(const char *); +#define MAXSWAP 100 + +static void usage(void); static int is_swapoff(const char *); +static int is_swapon(const char *); +static int is_swapctl(const char *); intswap_on_off(char *name, int ignoreebusy, int do_swapoff); +void swaplist(int, int, int); int main(int argc, char **argv) @@ -63,41 +70,68 @@ struct fstab *fsp; int stat; int ch, doall; - int do_swapoff; - char *pname = argv[0]; - - do_swapoff = is_swapoff(pname); - + int do_swapoff, do_swapon; + int sflag = 0, lflag = 0, hflag = 0; + + do_swapoff = is_swapoff(getprogname()); + do_swapon = is_swapon(getprogname()); + doall = 0; - while ((ch = getopt(argc, argv, a)) != -1) - switch((char)ch) { + while ((ch = getopt(argc, argv, alhsU)) != -1) + switch(ch) { case 'a': doall = 1; break; + case 's': + sflag = 1; + break; + case 'l': + lflag = 1; + break; + case 'h': + hflag = 1; + break; + case 'U': + if (!do_swapon) { + doall = 1; + do_swapoff = 1; + break; + } /* Remove the if if you want the U switch to work with +swapon also, don't know if that is wanted */ case '?': default: - usage(pname); + usage(); } argv += optind; - + stat = 0; - if (doall) - while ((fsp = getfsent()) != NULL) { - if (strcmp(fsp-fs_type, FSTAB_SW)) - continue; - if (strstr(fsp-fs_mntops, noauto)) - continue; - if (swap_on_off(fsp-fs_spec, 1, do_swapoff)) - stat = 1; - else - printf(%s: %sing %s as swap device\n, - pname, do_swapoff ? remov : add, - fsp-fs_spec); + if (do_swapoff || do_swapon) { + if (doall) { + while ((fsp = getfsent()) != NULL) { + if (strcmp(fsp-fs_type, FSTAB_SW)) + continue; + if (strstr(fsp-fs_mntops, noauto)) + continue; + if (swap_on_off(fsp-fs_spec, 1, do_swapoff)) + stat = 1; + else + printf(%s: %sing %s as swap device\n, + getprogname(), do_swapoff ? remov
Re: swapoff code comitted.
On Wed, Dec 18, 2002 at 11:18:24AM -0800, Matthew Dillon wrote: :I have made a small patch, added l, s and h switches to show :information about the swap devices. And the U switch to swapctl only :to remove all activated swap devices. :If anything else is needed let me know and I will add it. : :--=20 : :Eirik Nygaard [EMAIL PROTECTED] :PGP Key: 83C55EDE That is a pretty good first attempt. I have a few suggests and found one bug. First the bug: :+is_swapctl ? lsU : ); I think that was supposed to be a call to is_swapctl, not a pointer to the function. Suggestions: Get rid of the is_swap*() functions and instead use av[0] at the top of main() and use strstr() to determine if the program is swapon, swapoff, or swapctl. Check against swapon and swapoff and if it is neither then default to swapctl (don't test against swapctl). Store which program it is in a global variable, e.g. an enum like this: enum { SWAPON, SWAPOFF, SWAPCTL } which_prog = SWAPCTL; In regards to retrieving swap information, in -current there is a sysctl() to do it. Take a look at /usr/src/usr.sbin/pstat/pstat.c (in the current source tree), at the swapmode_kvm() and swapmode_sysctl() functions. The sysctl is much, much faster then the kvm call because the kvm call has to run through the swap radix tree to collect the useage information. Added the enum instead of is_swap* commands and changed from kvm to sysctl to get the swap information. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE ? sbin/swapon/.swapon.c.swp Index: sbin/swapon/Makefile === RCS file: /home/ncvs/src/sbin/swapon/Makefile,v retrieving revision 1.7 diff -u -r1.7 Makefile --- sbin/swapon/Makefile15 Dec 2002 19:17:56 - 1.7 +++ sbin/swapon/Makefile18 Dec 2002 20:35:53 - @@ -3,7 +3,9 @@ PROG= swapon MAN= swapon.8 -LINKS= ${BINDIR}/swapon ${BINDIR}/swapoff -MLINKS=swapon.8 swapoff.8 +LINKS= ${BINDIR}/swapoff ${BINDIR}/swapon +LINKS+=${BINDIR}/swapctl ${BINDIR}/swapon +MLINKS=swapoff.8 swapon.8 +MLINKS=swapctl.8 swapon.8 .include bsd.prog.mk Index: sbin/swapon/swapon.c === RCS file: /home/ncvs/src/sbin/swapon/swapon.c,v retrieving revision 1.13 diff -u -r1.13 swapon.c --- sbin/swapon/swapon.c15 Dec 2002 19:17:56 - 1.13 +++ sbin/swapon/swapon.c18 Dec 2002 20:35:53 - @@ -45,6 +45,11 @@ $FreeBSD: src/sbin/swapon/swapon.c,v 1.13 2002/12/15 19:17:56 dillon Exp $; #endif /* not lint */ +#include sys/stat.h +#include sys/param.h +#include sys/user.h +#include sys/sysctl.h + #include err.h #include errno.h #include fstab.h @@ -52,10 +57,13 @@ #include stdlib.h #include string.h #include unistd.h +#include fcntl.h + +static void usage(void); +intswap_on_off(char *name, int ignoreebusy); +void swaplist(int, int, int); -static void usage(const char *); -static int is_swapoff(const char *); -intswap_on_off(char *name, int ignoreebusy, int do_swapoff); +enum { SWAPON, SWAPOFF, SWAPCTL } which_prog = SWAPCTL; int main(int argc, char **argv) @@ -63,47 +71,80 @@ struct fstab *fsp; int stat; int ch, doall; - int do_swapoff; - char *pname = argv[0]; - - do_swapoff = is_swapoff(pname); - + int sflag = 0, lflag = 0, hflag = 0; + + if (strstr(argv[0], swapon)) + which_prog = SWAPON; + else if (strstr(argv[0], swapoff)) + which_prog = SWAPOFF; + doall = 0; - while ((ch = getopt(argc, argv, a)) != -1) - switch((char)ch) { + while ((ch = getopt(argc, argv, alhsU)) != -1) + switch(ch) { case 'a': doall = 1; break; + case 's': + sflag = 1; + break; + case 'l': + lflag = 1; + break; + case 'h': + hflag = 1; + break; + case 'U': + if (which_prog != SWAPON) { + doall = 1; + which_prog = SWAPOFF; + break; + } /* Remove the if if you want the U switch to work with +swapon also, don't know if that is wanted */ case '?': default: - usage(pname); + usage(); } argv += optind; - + stat = 0; - if (doall) - while ((fsp = getfsent()) != NULL) { - if (strcmp(fsp-fs_type, FSTAB_SW)) - continue
libdisk/rules.c broken
lib/libdisk/rules.c is broken in Check_Chunk(). cc -mcpu=pentiumpro -Werror -Wall -Wno-format-y2k -Wno-uninitialized -c rules.c -o rules.o cc1: warnings being treated as errors rules.c: In function `Check_Chunk': rules.c:254: warning: enumeration value `p_any' not handled in switch rules.c:254: warning: enumeration value `p_alpha' not handled in switch rules.c:254: warning: enumeration value `p_sparc64' not handled in switch rules.c:254: warning: enumeration value `p_ia64' not handled in switch rules.c:254: warning: enumeration value `p_ppc' not handled in switch *** Error code 1 A patch is attached. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE Index: rules.c === RCS file: /home/ncvs/src/lib/libdisk/rules.c,v retrieving revision 1.27 diff -u -r1.27 rules.c --- rules.c 31 Oct 2002 05:51:25 - 1.27 +++ rules.c 13 Nov 2002 21:25:16 - @@ -251,6 +251,12 @@ if (c-next) Check_Chunk(d, c-next, msg); break; + case p_alpha: + case p_sparc64: + case p_ia64: + case p_ppc: + case p_any: + break; } } msg46645/pgp0.pgp Description: PGP signature
Re: libdisk/rules.c broken
Sorry, forgot to give som version info, I am running -CURRENT as of 13 Nov. Uname: FreeBSD odin.eirikn.net 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Sun Nov 10 13:08:46 CET 2002 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/ITvision i386 On Wed, Nov 13, 2002 at 10:35:22PM +0100, Eirik Nygaard wrote: lib/libdisk/rules.c is broken in Check_Chunk(). cc -mcpu=pentiumpro -Werror -Wall -Wno-format-y2k -Wno-uninitialized -c rules.c -o rules.o cc1: warnings being treated as errors rules.c: In function `Check_Chunk': rules.c:254: warning: enumeration value `p_any' not handled in switch rules.c:254: warning: enumeration value `p_alpha' not handled in switch rules.c:254: warning: enumeration value `p_sparc64' not handled in switch rules.c:254: warning: enumeration value `p_ia64' not handled in switch rules.c:254: warning: enumeration value `p_ppc' not handled in switch *** Error code 1 A patch is attached. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE Index: rules.c === RCS file: /home/ncvs/src/lib/libdisk/rules.c,v retrieving revision 1.27 diff -u -r1.27 rules.c --- rules.c 31 Oct 2002 05:51:25 - 1.27 +++ rules.c 13 Nov 2002 21:25:16 - @@ -251,6 +251,12 @@ if (c-next) Check_Chunk(d, c-next, msg); break; + case p_alpha: + case p_sparc64: + case p_ia64: + case p_ppc: + case p_any: + break; } } -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE msg46662/pgp0.pgp Description: PGP signature
rmuser
I have rewritten the rmuser.perl script into C. But got no experiense with at, and I see the the perl port got a function that removes any at jobs for the user being removed. So I wonderd if anyone could make a patch that does that, any feedback on the code or bug reports would also be greate. I have sent in a mail once before, fixed all the style bugs since them :) The source is attached. -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE /* * Copyright 2002 Eirik Nygaard. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer as *the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY EIRIK NYGAARD ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL GUY HELMER BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * rmuser - C programme to remove users * * Eirik Nygaard [EMAIL PROTECTED], 08/08/02 * */ #include sys/cdefs.h __FBSDID($FreeBSD$); #include sys/types.h #include sys/file.h #include sys/stat.h #include sys/time.h #include sys/uio.h #include sys/wait.h #include sys/resource.h #include err.h #include fcntl.h #include dirent.h #include pwd.h #include signal.h #include stdio.h #include stdlib.h #include string.h #include sysexits.h #include unistd.h #include limits.h #include errno.h charpasswd_file[] = /etc/master.passwd; charpasswd_tmp[PATH_MAX] = /etc/ptmp.X; char*passwd_tmp2; chargroup_file[] = /etc/group; charnew_group_file[] = /etc/group.new; charmail_dir[] = /var/mail; charcrontab_dir[] = /var/cron/tabs; charpath[] = /bin:/sbin:/usr/bin:/usr/sbin; int yes;/* Always yes? */ int removehomedir = 1; char*user = NULL; /* User to delete */ charuser2[BUFSIZ]; charanswer[BUFSIZ]; int fp; FILE*fp2; charline[PATH_MAX + 50]; charhomedir[PATH_MAX]; struct passwd *password; struct stat sb; voidusage(); voidgetuser(); voidremove_files_from_dir(int uid, char *path); int recvnl( char *buf, int fd); voidupdate_passwd(); voidupdate_group(); voidkilluser(int uid, int gid); voiddel_mail(); voidsighandle(int sig); int main(int argc, char **argv) { int ch, numbuf = 0; /* Check for root */ if (getuid() != 0) errx(EX_NOPERM, You must be root to run this program.); signal(SIGINT, sighandle); signal(SIGTERM, sighandle); signal(SIGHUP, sighandle); signal(SIGQUIT, sighandle); /* Set the path we need */ setenv(PATH, path, 1); /* Set umode */ umask(022); /* Get command line arguments */ while ((ch = getopt(argc, argv, yu:)) != -1) { switch (ch) { case 'y': yes = 1; break; case 'u': user = optarg; break; case '?': default: usage(); } } if (user == NULL) { getuser(); } if ((password = getpwnam(user)) == NULL) errx(EX_NOUSER, No user found by that name: %s.\n, user); printf(\nMatching password entry: \n); printf(\t%s:%s:%d:%d:%s:%s\n, password-pw_name, password-pw_passwd, password-pw_uid, password-pw_gid, password-pw_dir, password-pw_shell); if (yes == 0) { printf(Is this the entry you wish to remove?(y/n) ); fgets(answer, sizeof(answer), stdin
Re: 5.0 package build with gcc32 complete (HELP NEEDED!!)
I got some free time on my hands and will try to fix some ports, already fixed sysutils/logmon. On Fri, Sep 06, 2002 at 11:58:17AM -0700, Kris Kennaway wrote: All ports maintainers/committers: please take a look at http://bento.freebsd.org/errorlogs/5-latest/ and consider fixing some ports. With the new gcc compiler we now have over 900 packages that are failing to build (an all-time record, AFAIK). Many of these are simple to fix and require less than 5 minutes of your time. Thanks for any help you can provide. Kris -- Eirik Nygaard [EMAIL PROTECTED] Http://kverka.org/~eirik/ PGP Key: 83C55EDE msg42740/pgp0.pgp Description: PGP signature
Re: troubles with the new GCC -- anyone else?
There is problem with several ports and gcc 3.2, which ports got the problem is maped and is put out on the web: http://bento.freebsd.org/errorlogs/5-latest/, some has been fixed. On Sun, Sep 08, 2002 at 02:30:06PM -0400, Mikhail Teterin wrote: Is it just me, or do others have troubles too? I upgraded yesterday: mi@celsius:~ (101) cc -v Using built-in specs. Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 3.2.1 [FreeBSD] 20020901 (prerelease) With ``-march=pentium2 -mmmx'' . there is a file or two in XFree86-4-Server, that cause an Internal Compiler Error -- fixed with ``-march=pentium2 -mno-mmx'' (same trouble existed with the previous version, AFAIR) . one file in libiconv causes ICE -- the workaround above does not work. But ``-march=pentium -mmmx'' works. . in the kdelibs3, the kdecore/kkeyserver_x11.cpp will not compile regardless of the architecture or optimization flags -- the ICE is in GCC's cp/cp-lang.c:130, due, it seems, to the initialization complexity. Can't think of a workaround :-\ Yours, -mi To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE msg42754/pgp0.pgp Description: PGP signature
rmuser.c - Updated source
Hello, I sent a mail about this program with a source a couple of days ago, not really pretty code, cleaned it up and gotten some help from #bsdcode@EFnet with some fixes. So I send the source again so you could take another look at it and tell me if I am missing something. -- Eirik Nygaard [EMAIL PROTECTED] Http://kverka.org/~eirik/ PGP Key: 83C55EDE /* * Copyright 2002 Eirik Nygaard. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer as *the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY EIRIK NYGAARD ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL GUY HELMER BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * rmuser - C programme to remove users * * Eirik Nygaard [EMAIL PROTECTED], 08/08/02 * */ #include sys/cdefs.h __FBSDID($FreeBSD$); #include sys/types.h #include sys/file.h #include sys/stat.h #include sys/time.h #include sys/uio.h #include sys/wait.h #include sys/resource.h #include err.h #include fcntl.h #include dirent.h #include pwd.h #include signal.h #include stdio.h #include stdlib.h #include string.h #include sysexits.h #include unistd.h #include limits.h #include errno.h charpasswd_file[] = /etc/master.passwd; charpasswd_tmp[PATH_MAX] = /etc/ptmp.X; char*passwd_tmp2; chargroup_file[] = /etc/group; charnew_group_file[] = /etc/group.new; charmail_dir[] = /var/mail; charcrontab_dir[] = /var/cron/tabs; charpath[] = /bin:/sbin:/usr/bin:/usr/sbin; int yes;/* Always yes? */ int removehomedir = 1; char*user = NULL; /* User to delete */ charuser2[BUFSIZ]; charanswer[BUFSIZ]; int fp; FILE*fp2; charline[PATH_MAX + 50]; charhomedir[PATH_MAX]; struct passwd *password; struct stat sb; voidusage(); voidgetuser(); voidremove_files_from_dir(int uid, char *path); int recvnl( char *buf, int fd); voidupdate_passwd(); voidupdate_group(); voidkilluser(int uid, int gid); voiddel_mail(); voidsighandle(int sig); int main(int argc, char **argv) { int ch, numbuf = 0; /* Check for root */ if (getuid() != 0) { errx(EX_NOPERM, You must be root to run this program.); } signal(SIGINT, sighandle); signal(SIGTERM, sighandle); signal(SIGHUP, sighandle); signal(SIGQUIT, sighandle); /* Set the path we need */ setenv(PATH, path, 1); /* Set umode */ umask(022); /* Get command line arguments */ while ((ch = getopt(argc, argv, yu:)) != -1) { switch (ch) { case 'y': yes = 1; break; case 'u': user = optarg; break; case '?': default: usage(); } } if (user == NULL) { getuser(); } if ((password = getpwnam(user)) == NULL) { errx(EX_NOUSER, No user found by that name: %s.\n, user); } printf(\nMatching password entry: \n); printf(\t%s:%s:%d:%d:%s:%s\n, password-pw_name, password-pw_passwd, password-pw_uid, password-pw_gid, password-pw_dir, password-pw_shell); if (yes == 0) { printf(Is this the entry you wish to remove?(y/n) ); fgets(answer, sizeof(answer), stdin); if (strncmp(answer, y, 1) != 0 strncmp(answer, Y, 1) != 0
Rewrite of the perl script rmuser to C
I have just rewritten the rmuser perl script to C, it would be great if you could take a look at it and check if everything is ok. How do I get this commited? -- Eirik Nygaard [EMAIL PROTECTED] PGP Key: 83C55EDE /* ** -*- perl -*- ** Copyright 1995, 1996, 1997 Guy Helmer, Ames, Iowa 50014. ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright **notice, this list of conditions and the following disclaimer as **the first lines of this file unmodified. ** 2. Redistributions in binary form must reproduce the above copyright **notice, this list of conditions and the following disclaimer in the **documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY GUY HELMER ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL GUY HELMER BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ** rmuser - C programme to remove users ** ** Eirik Nygaard [EMAIL PROTECTED], 08/08/02 ** ** $FreeBSD$ */ /* ** TODO: ** Add an at remove function */ #include stdio.h #include string.h #include stdlib.h #include unistd.h #include sys/file.h #include fcntl.h #include sys/stat.h #include sys/types.h #include pwd.h #include dirent.h #include sys/uio.h #include sys/time.h #include sys/resource.h #include signal.h #include sys/wait.h char passwd_file[] = /etc/master.passwd; char passwd_tmp[] = /etc/ptmp; char group_file[] = /etc/group; char new_group_file[] = /etc/group.new; char mail_dir[] = /var/mail; char crontab_dir[] = /var/cron/tabs; char path[] = /bin:/sbin:/usr/bin:/usr/sbin; int yes = 0; // Always yes? int removehomedir = 1; char *user = NULL; // User to delete char user2[400]; char answer[400]; int fp; FILE *fp2; char line[1024]; char homedir[1024]; struct passwd *password; struct stat sb; void usage(char *progname); void getuser(); void remove_files_from_dir(int uid, char *path); int recvnl( char *buf, int fd); void update_passwd(); void update_group(); void killuser(int uid, int gid); void del_mail(); void sig_handler1(); void sig_handler2(); void sig_handler3(); void sig_handler4(); int main(int argc, char **argv) { int ch, numbuf = 0; char string[1024], string2[1024], *p; struct sigaction sa; /* Check for root */ if (getuid() != 0) { printf(You must be root to run this program.\n); _exit(-2); } sa.sa_handler = sig_handler1; sigemptyset(sa.sa_mask); sa.sa_flags = SA_RESTART; sigaction(SIGINT, sa, NULL); sa.sa_handler = sig_handler2; sigaction(SIGQUIT, sa, NULL); sa.sa_handler = sig_handler3; sigaction(SIGHUP, sa, NULL); sa.sa_handler = sig_handler4; sigaction(SIGTERM, sa, NULL); /* Set the path we need */ setenv(PATH, path, 1); /* Set umode */ umask(022); /* Get command line arguments */ while ((ch = getopt(argc, argv, yu:)) != -1) { switch (ch) { case 'y': yes = 1; break; case 'u': user = optarg; break; case '?': default: usage(argv[0]); } } if ((fp = open(passwd_file, O_RDONLY)) == NULL) { printf(Unable to open passwd file(%s).\n, passwd_file); _exit(-3); } fcntl(fp, F_SETFD, 1); if (flock(fp, LOCK_EX|LOCK_NB) == -1) { printf(Unable to lock passwd file(%s).\n, passwd_file); _exit(-4); } if (user == NULL) { getuser(); } while (recvnl(string, fp) != -1) { strcpy(string2, string); if ((p = strtok(string, :)) != NULL) { if (strcasecmp(p, user) == 0
[no subject]
help To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message