PERFORCE change 151667 for review
Sam Leffler
sam at FreeBSD.org
Tue Oct 21 16:31:11 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=151667
Change 151667 by sam at sam_ebb on 2008/10/21 16:30:32
IFC @ 151661
Affected files ...
.. //depot/projects/vap/contrib/tcsh/sh.c#3 integrate
.. //depot/projects/vap/contrib/tcsh/tc.const.c#3 integrate
.. //depot/projects/vap/crypto/openssh/loginrec.c#4 integrate
.. //depot/projects/vap/crypto/openssh/sshd.c#4 integrate
.. //depot/projects/vap/lib/libarchive/archive_read_support_format_zip.c#8 integrate
.. //depot/projects/vap/lib/libarchive/archive_util.c#6 integrate
.. //depot/projects/vap/lib/libarchive/test/test_read_format_zip.c#7 integrate
.. //depot/projects/vap/lib/libarchive/test/test_read_format_zip.zip.uu#2 integrate
.. //depot/projects/vap/lib/libc/string/strlcpy.c#3 integrate
.. //depot/projects/vap/lib/libc/string/strxfrm.c#4 integrate
.. //depot/projects/vap/lib/libutil/flopen.3#3 integrate
.. //depot/projects/vap/lib/libutil/flopen.c#3 integrate
.. //depot/projects/vap/lib/libutil/login_cap.h#4 integrate
.. //depot/projects/vap/lib/libutil/login_class.3#4 integrate
.. //depot/projects/vap/lib/libutil/login_class.c#5 integrate
.. //depot/projects/vap/lib/libutil/login_times.3#3 integrate
.. //depot/projects/vap/lib/libutil/login_times.c#4 integrate
.. //depot/projects/vap/lib/libutil/pidfile.3#3 integrate
.. //depot/projects/vap/lib/libutil/pidfile.c#3 integrate
.. //depot/projects/vap/sbin/geom/class/part/geom_part.c#7 integrate
.. //depot/projects/vap/sbin/ifconfig/ifconfig.8#20 integrate
.. //depot/projects/vap/share/man/man4/u3g.4#2 integrate
.. //depot/projects/vap/share/man/man9/vinvalbuf.9#3 integrate
.. //depot/projects/vap/sys/amd64/amd64/identcpu.c#11 integrate
.. //depot/projects/vap/sys/amd64/amd64/initcpu.c#5 integrate
.. //depot/projects/vap/sys/amd64/amd64/prof_machdep.c#7 integrate
.. //depot/projects/vap/sys/amd64/amd64/tsc.c#5 integrate
.. //depot/projects/vap/sys/amd64/include/clock.h#8 integrate
.. //depot/projects/vap/sys/amd64/include/md_var.h#5 integrate
.. //depot/projects/vap/sys/amd64/include/specialreg.h#10 integrate
.. //depot/projects/vap/sys/amd64/linux32/linux.h#7 integrate
.. //depot/projects/vap/sys/amd64/linux32/linux32_sysvec.c#11 integrate
.. //depot/projects/vap/sys/compat/linux/linux_signal.c#6 integrate
.. //depot/projects/vap/sys/compat/linux/linux_signal.h#5 integrate
.. //depot/projects/vap/sys/contrib/altq/altq/altq_subr.c#7 integrate
.. //depot/projects/vap/sys/dev/age/if_age.c#5 integrate
.. //depot/projects/vap/sys/dev/age/if_agevar.h#2 integrate
.. //depot/projects/vap/sys/dev/ath/if_ath.c#111 integrate
.. //depot/projects/vap/sys/dev/sound/pci/hda/hdac.c#12 integrate
.. //depot/projects/vap/sys/geom/part/g_part_pc98.c#6 integrate
.. //depot/projects/vap/sys/i386/cpufreq/powernow.c#7 integrate
.. //depot/projects/vap/sys/i386/i386/apic_vector.s#6 integrate
.. //depot/projects/vap/sys/i386/i386/identcpu.c#11 integrate
.. //depot/projects/vap/sys/i386/i386/initcpu.c#6 integrate
.. //depot/projects/vap/sys/i386/i386/trap.c#13 integrate
.. //depot/projects/vap/sys/i386/i386/tsc.c#5 integrate
.. //depot/projects/vap/sys/i386/include/apicvar.h#6 integrate
.. //depot/projects/vap/sys/i386/include/clock.h#9 integrate
.. //depot/projects/vap/sys/i386/include/md_var.h#6 integrate
.. //depot/projects/vap/sys/i386/include/smp.h#9 integrate
.. //depot/projects/vap/sys/i386/include/specialreg.h#9 integrate
.. //depot/projects/vap/sys/i386/include/xen/evtchn.h#3 integrate
.. //depot/projects/vap/sys/i386/include/xen/xen-os.h#3 integrate
.. //depot/projects/vap/sys/i386/include/xen/xen_intr.h#2 integrate
.. //depot/projects/vap/sys/i386/include/xen/xenfunc.h#3 integrate
.. //depot/projects/vap/sys/i386/isa/prof_machdep.c#7 integrate
.. //depot/projects/vap/sys/i386/linux/linux.h#8 integrate
.. //depot/projects/vap/sys/i386/linux/linux_sysvec.c#11 integrate
.. //depot/projects/vap/sys/i386/xen/clock.c#3 integrate
.. //depot/projects/vap/sys/i386/xen/exception.s#3 integrate
.. //depot/projects/vap/sys/i386/xen/mp_machdep.c#4 integrate
.. //depot/projects/vap/sys/ia64/ia64/mp_machdep.c#9 integrate
.. //depot/projects/vap/sys/kern/kern_time.c#7 integrate
.. //depot/projects/vap/sys/kern/subr_stack.c#5 integrate
.. //depot/projects/vap/sys/kern/subr_witness.c#21 integrate
.. //depot/projects/vap/sys/kern/tty.c#16 integrate
.. //depot/projects/vap/sys/kern/vfs_subr.c#24 integrate
.. //depot/projects/vap/sys/kern/vfs_vnops.c#12 integrate
.. //depot/projects/vap/sys/netinet/in_pcb.c#21 integrate
.. //depot/projects/vap/sys/netinet/in_pcb.h#15 integrate
.. //depot/projects/vap/sys/netinet6/in6_src.c#12 integrate
.. //depot/projects/vap/sys/sys/param.h#31 integrate
.. //depot/projects/vap/sys/ufs/ffs/ffs_vnops.c#13 integrate
.. //depot/projects/vap/tools/regression/lib/libutil/test-flopen.c#3 integrate
.. //depot/projects/vap/tools/tools/nanobsd/nanobsd.sh#11 integrate
Differences ...
==== //depot/projects/vap/contrib/tcsh/sh.c#3 (text+ko) ====
@@ -462,7 +462,7 @@
else
cp2 = cp;
if (!(((Strncmp(cp2, STRtty, 3) == 0) && Isalpha(cp2[3])) ||
- Strstr(cp, STRslptssl) != NULL)) {
+ Strstr(cp, STRptssl) != NULL)) {
if (getenv("DISPLAY") == NULL) {
/* NOT on X window shells */
setcopy(STRautologout, STRdefautologout, VAR_READWRITE);
==== //depot/projects/vap/contrib/tcsh/tc.const.c#3 (text+ko) ====
@@ -46,7 +46,7 @@
Char STRhangup[] = { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
Char STRaout[] = { 'a', '.', 'o', 'u', 't', '\0' };
Char STRtty[] = { 't', 't', 'y', '\0' };
-Char STRslptssl[] = { '/', 'p', 't', 's', '/', '\0' };
+Char STRptssl[] = { 'p', 't', 's', '/', '\0' };
Char STRany[] = { 'a', 'n', 'y', '\0' };
Char STRstatus[] = { 's', 't', 'a', 't', 'u', 's', '\0' };
Char STR0[] = { '0', '\0' };
==== //depot/projects/vap/crypto/openssh/loginrec.c#4 (text+ko) ====
@@ -146,7 +146,6 @@
*/
#include "includes.h"
-__RCSID("$FreeBSD: src/crypto/openssh/loginrec.c,v 1.15 2008/08/01 02:48:36 des Exp $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -689,8 +688,8 @@
strncpy(ut->ut_name, li->username,
MIN_SIZEOF(ut->ut_name, li->username));
# ifdef HAVE_HOST_IN_UTMP
- realhostname_sa(ut->ut_host, sizeof ut->ut_host,
- &li->hostaddr.sa, li->hostaddr.sa.sa_len);
+ strncpy(ut->ut_host, li->hostname,
+ MIN_SIZEOF(ut->ut_host, li->hostname));
# endif
# ifdef HAVE_ADDR_IN_UTMP
/* this is just a 32-bit IP address */
==== //depot/projects/vap/crypto/openssh/sshd.c#4 (text+ko) ====
@@ -43,7 +43,7 @@
*/
#include "includes.h"
-__RCSID("$FreeBSD: src/crypto/openssh/sshd.c,v 1.46 2008/08/01 02:48:36 des Exp $");
+__RCSID("$FreeBSD: src/crypto/openssh/sshd.c,v 1.47 2008/10/21 11:58:26 des Exp $");
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -72,6 +72,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <utmp.h>
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -238,7 +239,7 @@
u_int session_id2_len = 0;
/* record remote hostname or ip */
-u_int utmp_len = MAXHOSTNAMELEN;
+u_int utmp_len = UT_HOSTSIZE;
/* options.max_startup sized array of fd ints */
int *startup_pipes = NULL;
==== //depot/projects/vap/lib/libarchive/archive_read_support_format_zip.c#8 (text+ko) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.26 2008/06/30 16:19:26 des Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.27 2008/10/21 05:08:35 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -444,7 +444,9 @@
archive_entry_set_mtime(entry, zip->mtime, 0);
archive_entry_set_ctime(entry, zip->ctime, 0);
archive_entry_set_atime(entry, zip->atime, 0);
- archive_entry_set_size(entry, zip->uncompressed_size);
+ /* Set the size only if it's meaningful. */
+ if (0 == (zip->flags & ZIP_LENGTH_AT_END))
+ archive_entry_set_size(entry, zip->uncompressed_size);
zip->entry_bytes_remaining = zip->compressed_size;
zip->entry_offset = 0;
@@ -573,12 +575,16 @@
}
break;
}
+ if (r != ARCHIVE_OK)
+ return (r);
/* Update checksum */
- if (r == ARCHIVE_OK && *size) {
+ if (*size)
zip->entry_crc32 =
crc32(zip->entry_crc32, *buff, *size);
- }
- return (r);
+ /* Return EOF immediately if this is a non-regular file. */
+ if (AE_IFREG != (zip->mode & AE_IFMT))
+ return (ARCHIVE_EOF);
+ return (ARCHIVE_OK);
}
/*
==== //depot/projects/vap/lib/libarchive/archive_util.c#6 (text+ko) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.19 2008/10/21 12:10:30 des Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -168,6 +168,7 @@
va_start(ap, fmt);
archive_string_vsprintf(&(a->error_string), fmt, ap);
+ va_end(ap);
if (error_number > 0) {
archive_strcat(&(a->error_string), ": ");
#ifdef HAVE_STRERROR_R
@@ -184,7 +185,6 @@
archive_strcat(&(a->error_string), errp);
}
a->error = a->error_string.s;
- va_end(ap);
}
void
==== //depot/projects/vap/lib/libarchive/test/test_read_format_zip.c#7 (text+ko) ====
@@ -23,7 +23,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.7 2008/09/01 05:38:33 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.8 2008/10/21 05:08:35 kientzle Exp $");
+
+/*
+ * The reference file for this has been manually tweaked so that:
+ * * file2 has length-at-end but file1 does not
+ * * file2 has an invalid CRC
+ */
DEFINE_TEST(test_read_format_zip)
{
@@ -57,7 +63,8 @@
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("file2", archive_entry_pathname(ae));
assertEqualInt(1179605932, archive_entry_mtime(ae));
- assertEqualInt(18, archive_entry_size(ae));
+ failure("file2 has length-at-end, so we shouldn't see a valid size");
+ assertEqualInt(0, archive_entry_size_is_set(ae));
failure("file2 has a bad CRC, so reading to end should fail");
assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19));
assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
==== //depot/projects/vap/lib/libarchive/test/test_read_format_zip.zip.uu#2 (text+ko) ====
@@ -1,13 +1,14 @@
-$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.2 2008/06/26 11:50:11 des Exp $
+$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.3 2008/10/21 05:08:35 kientzle Exp $
begin 644 test_read_format_zip.zip
-M4$L#!`H``````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1AE5
-M3T95>`0`Z`/H`U!+`P04````"`!O9K,V.C=F/0H````2````!0`5`&9I;&4Q
-M550)``-!54]&K%M/1E5X!`#H`^@#RTC-R<GGRD`B`5!+`P04````"`!::K,V
-M>%8T$@H````2````!0`5`&9I;&4R550)``.L6T]&K%M/1E5X!`#H`^@#RTC-
-MR<GGRD`B`5!+`0(7`PH``````%EFLS8````````````````$``T`````````
-M$`#M00````!D:7(O550%``,954]&57@``%!+`0(7`Q0````(`&]FLS8Z-V8]
-M"@```!(````%``T```````$```"D at 3<```!F:6QE,554!0`#055/1E5X``!0
-M2P$"%P,4````"`!::K,V>%8T$@H````2````!0`-```````!````I(%Y````
-H9FEL93)55`4``ZQ;3T95>```4$L%!@`````#``,`OP```+L`````````
+M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19
+M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT*
+M````$@````4`%0!F:6QE,554"0`#055/1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`
+M(@%02P,$%``(``@`6FJS-@``````````$@````4`%0!F:6QE,E54"0`#K%M/
+M1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`(@%02P<(.C=F$@H````2````4$L!`A<#
+M"@`(````66:S-@````````````````0`#0`````````0`.U!`````&1I<B]5
+M5`4``QE53T95>```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0``
+M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ
+MLS8Z-V8]"@```!(````%``T```````$```#M at 8D```!F:6QE,E54!0`#K%M/
+;1E5X``!02P4&``````,``P"_````VP``````
`
end
==== //depot/projects/vap/lib/libc/string/strlcpy.c#3 (text+ko) ====
@@ -1,37 +1,23 @@
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller at courtesan.com>
- * 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.
- * 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.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * THIS SOFTWARE IS PROVIDED ``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
- * THE AUTHOR 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.9 2006/06/15 15:56:55 maxim Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.10 2008/10/19 10:11:35 delphij Exp $");
#include <sys/types.h>
#include <string.h>
@@ -42,21 +28,18 @@
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
-strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
+strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
break;
- } while (--n != 0);
+ }
}
/* Not enough room in dst, add NUL and traverse rest of src */
==== //depot/projects/vap/lib/libc/string/strxfrm.c#4 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/string/strxfrm.c,v 1.16 2008/10/17 21:29:05 delphij Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/string/strxfrm.c,v 1.17 2008/10/19 09:10:44 delphij Exp $");
#include <stdlib.h>
#include <string.h>
@@ -45,17 +45,8 @@
return 0;
}
- if (__collate_load_error) {
- slen = strlen(src);
- if (len > 0) {
- if (slen < len)
- strcpy(dest, src);
- else {
- strlcpy(dest, src, len);
- }
- }
- return slen;
- }
+ if (__collate_load_error)
+ return strlcpy(dest, src, len);
slen = 0;
prim = sec = 0;
==== //depot/projects/vap/lib/libutil/flopen.3#3 (text+ko) ====
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libutil/flopen.3,v 1.6 2007/09/28 15:31:44 obrien Exp $
+.\" $FreeBSD: src/lib/libutil/flopen.3,v 1.7 2008/10/20 18:02:16 des Exp $
.\"
.Dd May 10, 2007
.Dt FLOPEN 3
@@ -46,12 +46,13 @@
function opens or creates a file and acquires an exclusive lock on it.
It is essentially equivalent with calling
.Fn open
-with the same parameters followed by
-.Fn flock
-with an
-.Va operation
-argument of
-.Dv LOCK_EX ,
+with the same parameters followed by an
+.Fn fcntl
+.Dv F_SETLK
+or
+.Dv F_SETLKW
+operation with lock type
+.Dv F_WRLCK ,
except that
.Fn flopen
will attempt to detect and handle races that may occur between opening
@@ -86,12 +87,12 @@
Otherwise, it returns -1, and sets
.Va errno
as described in
-.Xr flock 2
+.Xr fcntl 2
and
.Xr open 2 .
.Sh SEE ALSO
.Xr errno 2 ,
-.Xr flock 2 ,
+.Xr fcntl 2 ,
.Xr open 2
.Sh HISTORY
The
==== //depot/projects/vap/lib/libutil/flopen.c#3 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,14 +26,14 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libutil/flopen.c,v 1.9 2007/08/03 09:20:28 des Exp $");
+__FBSDID("$FreeBSD: src/lib/libutil/flopen.c,v 1.11 2008/10/20 18:11:30 des Exp $");
-#include <sys/file.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <string.h>
#include <unistd.h>
#include <libutil.h>
@@ -42,6 +42,7 @@
flopen(const char *path, int flags, ...)
{
int fd, operation, serrno, trunc;
+ struct flock lock;
struct stat sb, fsb;
mode_t mode;
@@ -54,13 +55,14 @@
va_list ap;
va_start(ap, flags);
- mode = va_arg(ap, int); /* mode_t promoted to int */
+ mode = (mode_t)va_arg(ap, int); /* mode_t promoted to int */
va_end(ap);
}
- operation = LOCK_EX;
- if (flags & O_NONBLOCK)
- operation |= LOCK_NB;
+ memset(&lock, 0, sizeof lock);
+ lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK;
+ lock.l_whence = SEEK_SET;
+ operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
trunc = (flags & O_TRUNC);
flags &= ~O_TRUNC;
@@ -69,35 +71,35 @@
if ((fd = open(path, flags, mode)) == -1)
/* non-existent or no access */
return (-1);
- if (flock(fd, operation) == -1) {
+ if (fcntl(fd, operation, &lock) == -1) {
/* unsupported or interrupted */
serrno = errno;
- close(fd);
+ (void)close(fd);
errno = serrno;
return (-1);
}
if (stat(path, &sb) == -1) {
/* disappeared from under our feet */
- close(fd);
+ (void)close(fd);
continue;
}
if (fstat(fd, &fsb) == -1) {
/* can't happen [tm] */
serrno = errno;
- close(fd);
+ (void)close(fd);
errno = serrno;
return (-1);
}
if (sb.st_dev != fsb.st_dev ||
sb.st_ino != fsb.st_ino) {
/* changed under our feet */
- close(fd);
+ (void)close(fd);
continue;
}
if (trunc && ftruncate(fd, 0) != 0) {
/* can't happen [tm] */
serrno = errno;
- close(fd);
+ (void)close(fd);
errno = serrno;
return (-1);
}
==== //depot/projects/vap/lib/libutil/login_cap.h#4 (text+ko) ====
@@ -22,7 +22,7 @@
* Low-level routines relating to the user capabilities database
*
* Was login_cap.h,v 1.9 1997/05/07 20:00:01 eivind Exp
- * $FreeBSD: src/lib/libutil/login_cap.h,v 1.10 2008/07/25 19:58:14 brooks Exp $
+ * $FreeBSD: src/lib/libutil/login_cap.h,v 1.13 2008/10/20 17:17:58 des Exp $
*/
#ifndef _LOGIN_CAP_H_
@@ -81,7 +81,7 @@
#define LTM_NONE 0x00
#define LTM_SUN 0x01
#define LTM_MON 0x02
-#define LTM_TUE 0x04
+#define LTM_TUE 0x04
#define LTM_WED 0x08
#define LTM_THU 0x10
#define LTM_FRI 0x20
@@ -104,7 +104,8 @@
login_cap_t *login_getpwclass(const struct passwd *);
login_cap_t *login_getuserclass(const struct passwd *);
-const char *login_getcapstr(login_cap_t*, const char *, const char *, const char *);
+const char *login_getcapstr(login_cap_t *, const char *, const char *,
+ const char *);
const char **login_getcaplist(login_cap_t *, const char *, const char *);
const char *login_getstyle(login_cap_t *, const char *, const char *);
rlim_t login_getcaptime(login_cap_t *, const char *, rlim_t, rlim_t);
@@ -114,45 +115,51 @@
int login_getcapbool(login_cap_t *, const char *, int);
const char *login_setcryptfmt(login_cap_t *, const char *, const char *);
-int setclasscontext(const char*, unsigned int);
-int setusercontext(login_cap_t*, const struct passwd*, uid_t, unsigned int);
+int setclasscontext(const char *, unsigned int);
+void setclasscpumask(login_cap_t *);
+int setusercontext(login_cap_t *, const struct passwd *, uid_t, unsigned int);
void setclassresources(login_cap_t *);
void setclassenvironment(login_cap_t *, const struct passwd *, int);
/* Most of these functions are deprecated */
-int auth_approve(login_cap_t*, const char*, const char*);
+int auth_approve(login_cap_t *, const char *, const char *);
int auth_check(const char *, const char *, const char *, const char *, int *);
void auth_env(void);
-char *auth_mkvalue(const char *n);
-int auth_response(const char *, const char *, const char *, const char *, int *, const char *, const char *);
+char *auth_mkvalue(const char *);
+int auth_response(const char *, const char *, const char *, const char *, int *,
+ const char *, const char *);
void auth_rmfiles(void);
int auth_scan(int);
-int auth_script(const char*, ...);
+int auth_script(const char *, ...);
int auth_script_data(const char *, int, const char *, ...);
char *auth_valud(const char *);
int auth_setopt(const char *, const char *);
void auth_clropts(void);
-void auth_checknologin(login_cap_t*);
-int auth_cat(const char*);
+void auth_checknologin(login_cap_t *);
+int auth_cat(const char *);
-int auth_ttyok(login_cap_t*, const char *);
-int auth_hostok(login_cap_t*, const char *, char const *);
-int auth_timeok(login_cap_t*, time_t);
+int auth_ttyok(login_cap_t *, const char *);
+int auth_hostok(login_cap_t *, const char *, char const *);
+int auth_timeok(login_cap_t *, time_t);
struct tm;
login_time_t parse_lt(const char *);
+int in_lt(const login_time_t *, time_t *);
int in_ltm(const login_time_t *, struct tm *, time_t *);
int in_ltms(const login_time_t *, struct tm *, time_t *);
+int in_lts(const login_time_t *, time_t *);
/* helper functions */
int login_strinlist(const char **, char const *, int);
int login_str2inlist(const char **, const char *, const char *, int);
-login_time_t * login_timelist(login_cap_t *, char const *, int *, login_time_t **);
+login_time_t * login_timelist(login_cap_t *, char const *, int *,
+ login_time_t **);
int login_ttyok(login_cap_t *, const char *, const char *, const char *);
-int login_hostok(login_cap_t *, const char *, const char *, const char *, const char *);
+int login_hostok(login_cap_t *, const char *, const char *, const char *,
+ const char *);
__END_DECLS
==== //depot/projects/vap/lib/libutil/login_class.3#4 (text+ko) ====
@@ -17,13 +17,14 @@
.\" 5. Modifications may be freely made to this file providing the above
.\" conditions are met.
.\"
-.\" $FreeBSD: src/lib/libutil/login_class.3,v 1.20 2008/07/25 19:58:14 brooks Exp $
+.\" $FreeBSD: src/lib/libutil/login_class.3,v 1.21 2008/10/20 17:03:05 des Exp $
.\"
-.Dd December 28, 1996
+.Dd October 20, 2008
.Os
.Dt LOGIN_CLASS 3
.Sh NAME
.Nm setclasscontext ,
+.Nm setclasscpumask ,
.Nm setclassenvironment ,
.Nm setclassresources ,
.Nm setusercontext
@@ -35,12 +36,14 @@
.In login_cap.h
.Ft int
.Fn setclasscontext "const char *classname" "unsigned int flags"
-.Ft int
-.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
.Ft void
-.Fn setclassresources "login_cap_t *lc"
+.Fn setclasscpumask "login_cap_t *lc"
.Ft void
.Fn setclassenvironment "login_cap_t *lc" "const struct passwd *pwd" "int paths"
+.Ft void
+.Fn setclassresources "login_cap_t *lc"
+.Ft int
+.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
.Sh DESCRIPTION
These functions provide a higher level interface to the login class
database than those documented in
@@ -162,7 +165,7 @@
The string may contain a comma separated list of numbers and/or number
ranges as handled by the
.Xr cpuset 1
-utility or the case-insensitive string
+utility or the case-insensitive string
.Ql default .
If the string is
.Ql default
@@ -182,6 +185,7 @@
respectively.
.Pp
The
+.Fn setclasscpumask ,
.Fn setclassresources
and
.Fn setclassenvironment
==== //depot/projects/vap/lib/libutil/login_class.c#5 (text+ko) ====
@@ -23,16 +23,18 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libutil/login_class.c,v 1.27 2008/08/20 08:31:58 ed Exp $");
+__FBSDID("$FreeBSD: src/lib/libutil/login_class.c,v 1.29 2008/10/20 16:51:43 des Exp $");
-#include <sys/types.h>
#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/resource.h>
#include <sys/cpuset.h>
#include <sys/mac.h>
+#include <sys/resource.h>
#include <sys/rtprio.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <ctype.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <login_cap.h>
@@ -92,7 +94,7 @@
if (getrlimit(lr->why, &rlim) != 0)
syslog(LOG_ERR, "getting %s resource limit: %m", lr->what);
else {
- char name_cur[40];
+ char name_cur[40];
char name_max[40];
rlim_t rcur = rlim.rlim_cur;
rlim_t rmax = rlim.rlim_max;
@@ -104,7 +106,7 @@
rmax = (*lr->who)(lc, lr->what, rmax, rmax);
rlim.rlim_cur = (*lr->who)(lc, name_cur, rcur, rcur);
rlim.rlim_max = (*lr->who)(lc, name_max, rmax, rmax);
-
+
if (setrlimit(lr->why, &rlim) == -1)
syslog(LOG_WARNING, "set class '%s' resource limit %s: %m", lc->lc_class, lr->what);
}
@@ -185,7 +187,7 @@
}
}
- return np;
+ return (np);
}
@@ -309,7 +311,7 @@
case DASH:
return (0);
}
- return 1;
+ return (1);
}
@@ -368,7 +370,7 @@
rc = lc ? setusercontext(lc, NULL, 0, flags) : -1;
login_close(lc);
- return rc;
+ return (rc);
}
@@ -398,7 +400,7 @@
if (flags & LOGIN_SETCPUMASK)
setclasscpumask(lc);
}
- return mymask;
+ return (mymask);
}
@@ -468,13 +470,13 @@
if (setgid(pwd->pw_gid) != 0) {
syslog(LOG_ERR, "setgid(%lu): %m", (u_long)pwd->pw_gid);
login_close(llc);
- return -1;
+ return (-1);
}
if (initgroups(pwd->pw_name, pwd->pw_gid) == -1) {
syslog(LOG_ERR, "initgroups(%s,%lu): %m", pwd->pw_name,
(u_long)pwd->pw_gid);
login_close(llc);
- return -1;
+ return (-1);
}
}
@@ -488,7 +490,7 @@
if (mac_from_text(&label, label_string) == -1) {
syslog(LOG_ERR, "mac_from_text('%s') for %s: %m",
pwd->pw_name, label_string);
- return -1;
+ return (-1);
}
if (mac_set_proc(label) == -1)
error = errno;
@@ -498,7 +500,7 @@
if (error != 0) {
syslog(LOG_ERR, "mac_set_proc('%s') for %s: %s",
label_string, pwd->pw_name, strerror(error));
- return -1;
+ return (-1);
}
}
}
@@ -507,7 +509,7 @@
if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) {
syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name);
login_close(llc);
- return -1;
+ return (-1);
}
mymask = (flags & LOGIN_SETUMASK) ? umask(LOGIN_DEFUMASK) : 0;
@@ -517,7 +519,7 @@
/* This needs to be done after anything that needs root privs */
if ((flags & LOGIN_SETUSER) && setuid(uid) != 0) {
syslog(LOG_ERR, "setuid(%lu): %m", (u_long)uid);
- return -1; /* Paranoia again */
+ return (-1); /* Paranoia again */
}
/*
@@ -532,6 +534,5 @@
if (flags & LOGIN_SETUMASK)
umask(mymask);
- return 0;
+ return (0);
}
-
==== //depot/projects/vap/lib/libutil/login_times.3#3 (text+ko) ====
@@ -17,15 +17,17 @@
.\" 5. Modifications may be freely made to this file providing the above
.\" conditions are met.
.\"
-.\" $FreeBSD: src/lib/libutil/login_times.3,v 1.15 2004/07/02 23:52:19 ru Exp $
+.\" $FreeBSD: src/lib/libutil/login_times.3,v 1.16 2008/10/20 17:17:58 des Exp $
.\"
-.Dd January 2, 1997
+.Dd October 20, 2008
.Os
.Dt LOGIN_TIMES 3
.Sh NAME
.Nm parse_lt ,
+.Nm in_lt ,
.Nm in_ltm ,
-.Nm in_ltms
+.Nm in_ltms ,
+.Nm in_lts
.Nd functions for parsing and checking login time periods
.Sh LIBRARY
.Lb libutil
@@ -36,9 +38,13 @@
.Ft login_time_t
.Fn parse_lt "const char *str"
.Ft int
+.Fn in_lt "const login_time_t *lt" "time_t *ends"
+.Ft int
.Fn in_ltm "const login_time_t *lt" "struct tm *t" "time_t *ends"
.Ft int
.Fn in_ltms "const login_time_t *lt" "struct tm *t" "time_t *ends"
+.Ft int
+.Fn in_lts "const login_time_t *lt" "time_t *ends"
.Sh DESCRIPTION
This set of functions may be used for parsing and checking login and
session times against a predefined list of allowed login times as
@@ -135,6 +141,18 @@
.Ar lt_dow
field set to
.Em LTM_NONE .
+.Pp
+The
+.Fn in_lt
+and
+.Fn in_lts
+functions are equivalent to
+.Fn in_ltm
+and
+.Fn in_ltms ,
+respectively, with the second argument set to the current time as
+returned by
+.Xr localtime 3 .
.Sh RETURN VALUES
The
.Fn parse_lt
==== //depot/projects/vap/lib/libutil/login_times.c#4 (text+ko) ====
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libutil/login_times.c,v 1.12 2008/10/17 21:21:14 delphij Exp $");
+__FBSDID("$FreeBSD: src/lib/libutil/login_times.c,v 1.15 2008/10/20 17:09:50 des Exp $");
#include <sys/types.h>
#include <ctype.h>
@@ -34,13 +34,13 @@
static struct
{
const char *dw;
- u_char cn;
- u_char fl;
+ u_char cn;
+ u_char fl;
} dws[] =
{
{ "su", 2, LTM_SUN }, { "mo", 2, LTM_MON }, { "tu", 2, LTM_TUE },
{ "we", 2, LTM_WED }, { "th", 2, LTM_THU }, { "fr", 2, LTM_FRI },
- { "sa", 2, LTM_SAT }, { "any",3, LTM_ANY }, { "all",3, LTM_ANY },
+ { "sa", 2, LTM_SAT }, { "any",3, LTM_ANY }, { "all",3, LTM_ANY },
{ "wk", 2, LTM_WK }, { "wd", 2, LTM_WD }, { NULL, 0, 0 }
};
@@ -54,27 +54,28 @@
*t = (u_short)((val / 100) * 60 + (val % 100));
- return ptr;
+ return (ptr);
}
login_time_t
-parse_lt(const char * str)
+parse_lt(const char *str)
{
login_time_t t;
memset(&t, 0, sizeof t);
t.lt_dow = LTM_NONE;
if (str && *str && strcmp(str, "Never") != 0 && strcmp(str, "None") != 0) {
- int i;
- login_time_t m = t;
+ int i;
+ login_time_t m = t;
char *p;
- char buf[64];
+ char buf[64];
/* Make local copy and force lowercase to simplify parsing */
- p = strlcpy(buf, str, sizeof buf);
+ strlcpy(buf, str, sizeof buf);
for (i = 0; buf[i]; i++)
buf[i] = (char)tolower(buf[i]);
+ p = buf;
while (isalpha(*p)) {
@@ -101,12 +102,12 @@
t = m;
}
- return t;
+ return (t);
}
int
-in_ltm(const login_time_t * ltm, struct tm * tt, time_t * ends)
+in_ltm(const login_time_t *ltm, struct tm *tt, time_t *ends)
{
int rc = 0;
@@ -129,32 +130,33 @@
}
}
}
- return rc;
+ return (rc);
}
int
-in_lt(const login_time_t * ltm, time_t * t)
+in_lt(const login_time_t *ltm, time_t *t)
{
- return in_ltm(ltm, localtime(t), t);
+
+ return (in_ltm(ltm, localtime(t), t));
}
int
-in_ltms(const login_time_t * ltm, struct tm * tm, time_t * t)
+in_ltms(const login_time_t *ltm, struct tm *tm, time_t *t)
{
int i = 0;
while (i < LC_MAXTIMES && ltm[i].lt_dow != LTM_NONE) {
if (in_ltm(ltm + i, tm, t))
- return i;
+ return (i);
i++;
}
- return -1;
+ return (-1);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list