=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sort/sort.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- src/usr.bin/sort/sort.c 1999/05/24 17:57:19 1.12 +++ src/usr.bin/sort/sort.c 1999/11/30 16:41:41 1.13 @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.12 1999/05/24 17:57:19 millert Exp $ */ +/* $OpenBSD: sort.c,v 1.13 1999/11/30 16:41:41 espie Exp $ */ /*- * Copyright (c) 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)sort.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: sort.c,v 1.12 1999/05/24 17:57:19 millert Exp $"; +static char rcsid[] = "$OpenBSD: sort.c,v 1.13 1999/11/30 16:41:41 espie Exp $"; #endif #endif /* not lint */ @@ -60,6 +60,8 @@ #include "fsort.h" #include "pathnames.h" +#include +#include #include #include #include @@ -264,6 +266,7 @@ int sigtable[] = {SIGHUP, SIGINT, SIGPIPE, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, 0}; int outfd; + mode_t um; errno = 0; @@ -272,7 +275,12 @@ act.sa_handler = onsig; (void)snprintf(toutpath, sizeof(toutpath), "%sXXXXXXXXXX", outpath); - if ((outfd = mkstemp(toutpath)) < 0 || + /* use default umask to try and avoid one syscall */ + um = umask(S_IWGRP|S_IWOTH); + if (um != S_IWGRP|S_IWOTH) + (void)umask(um); + if ((outfd = mkstemp(toutpath)) == -1 || + fchmod(outfd, DEFFILEMODE & ~um) == -1 || (outfp = fdopen(outfd, "w")) == 0) err(2, toutpath); outfile = toutpath;