svn commit: r223690 - head/usr.bin/quota

2011-06-30 Thread Sergey Kandaurov
Author: pluknet
Date: Thu Jun 30 09:20:26 2011
New Revision: 223690
URL: http://svn.freebsd.org/changeset/base/223690

Log:
  Fix quota(1) output.
  
  - Fix calculation of 1024-byte sized blocks from disk blocks shown when -h
  option isn't specified. It was broken with quota64 integration.
  - In prthumanval(): limit the size of a buffer passed to humanize_number()
  to a width of 5 bytes but allow a shorter length if requested. That's what
  users expect.
  
  PR:   bin/150151
  Reviewed by:  Kirk McKusick

Modified:
  head/usr.bin/quota/quota.c

Modified: head/usr.bin/quota/quota.c
==
--- head/usr.bin/quota/quota.c  Thu Jun 30 05:28:10 2011(r223689)
+++ head/usr.bin/quota/quota.c  Thu Jun 30 09:20:26 2011(r223690)
@@ -264,8 +264,11 @@ prthumanval(int len, u_int64_t bytes)
 {
char buf[len + 1];
 
-   humanize_number(buf, sizeof(buf), bytes, , HN_AUTOSCALE,
-   HN_B | HN_NOSPACE | HN_DECIMAL);
+   /*
+* Limit the width to 5 bytes as that is what users expect.
+*/
+   humanize_number(buf, sizeof(buf)  5 ? sizeof(buf) : 5, bytes, ,
+   HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
 
(void)printf( %*s, len, buf);
 }
@@ -352,10 +355,13 @@ showquotas(int type, u_long id, const ch
prthumanval(7, dbtob(qup-dqblk.dqb_bhardlimit));
} else {
printf( %7ju%c %7ju %7ju,
-   dbtob(1024) * (uintmax_t)qup-dqblk.dqb_curblocks,
+   (uintmax_t)dbtob(qup-dqblk.dqb_curblocks)
+   / 1024,
(msgb == NULL) ? ' ' : '*',
-   dbtob(1024) * (uintmax_t)qup-dqblk.dqb_bsoftlimit,
-   dbtob(1024) * (uintmax_t)qup-dqblk.dqb_bhardlimit);
+   (uintmax_t)dbtob(qup-dqblk.dqb_bsoftlimit)
+   / 1024,
+   (uintmax_t)dbtob(qup-dqblk.dqb_bhardlimit)
+   / 1024);
}
if (msgb != NULL)
bgrace = timeprt(qup-dqblk.dqb_btime);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r223694 - in head/sys: kern sys

2011-06-30 Thread Jonathan Anderson
Author: jonathan
Date: Thu Jun 30 15:22:49 2011
New Revision: 223694
URL: http://svn.freebsd.org/changeset/base/223694

Log:
  When Capsicum starts creating capabilities to wrap existing file
  descriptors, we will want to allocate a new descriptor without installing
  it in the FD array.
  
  Split falloc() into falloc_noinstall() and finstall(), and rewrite
  falloc() to call them with appropriate atomicity.
  
  Approved by: mentor (rwatson), re (bz)

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/filedesc.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cThu Jun 30 14:10:49 2011
(r223693)
+++ head/sys/kern/kern_descrip.cThu Jun 30 15:22:49 2011
(r223694)
@@ -1561,54 +1561,85 @@ fdavail(struct thread *td, int n)
 int
 falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags)
 {
-   struct proc *p = td-td_proc;
struct file *fp;
-   int error, i;
+   int error, fd;
+
+   error = falloc_noinstall(td, fp);
+   if (error)
+   return (error); /* no reference held on error */
+
+   error = finstall(td, fp, fd, flags);
+   if (error) {
+   fdrop(fp, td);  /* one reference (fp only) */
+   return (error);
+   }
+
+   if (resultfp != NULL)
+   *resultfp = fp; /* copy out result */
+   else
+   fdrop(fp, td);  /* release local reference */
+
+   if (resultfd != NULL)
+   *resultfd = fd;
+
+   return (0);
+}
+
+/*
+ * Create a new open file structure without allocating a file descriptor.
+ */
+int
+falloc_noinstall(struct thread *td, struct file **resultfp)
+{
+   struct file *fp;
int maxuserfiles = maxfiles - (maxfiles / 20);
static struct timeval lastfail;
static int curfail;
 
-   fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO);
+   KASSERT(resultfp != NULL, (%s: resultfp == NULL, __func__));
+
if ((openfiles = maxuserfiles 
priv_check(td, PRIV_MAXFILES) != 0) ||
openfiles = maxfiles) {
if (ppsratecheck(lastfail, curfail, 1)) {
-   printf(kern.maxfiles limit exceeded by uid %i, please 
see tuning(7).\n,
-   td-td_ucred-cr_ruid);
+   printf(kern.maxfiles limit exceeded by uid %i, 
+   please see tuning(7).\n, td-td_ucred-cr_ruid);
}
-   uma_zfree(file_zone, fp);
return (ENFILE);
}
atomic_add_int(openfiles, 1);
-
-   /*
-* If the process has file descriptor zero open, add the new file
-* descriptor to the list of open files at that point, otherwise
-* put it at the front of the list of open files.
-*/
+   fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO);
refcount_init(fp-f_count, 1);
-   if (resultfp)
-   fhold(fp);
fp-f_cred = crhold(td-td_ucred);
fp-f_ops = badfileops;
fp-f_data = NULL;
fp-f_vnode = NULL;
-   FILEDESC_XLOCK(p-p_fd);
-   if ((error = fdalloc(td, 0, i))) {
-   FILEDESC_XUNLOCK(p-p_fd);
-   fdrop(fp, td);
-   if (resultfp)
-   fdrop(fp, td);
+   *resultfp = fp;
+   return (0);
+}
+
+/*
+ * Install a file in a file descriptor table.
+ */
+int
+finstall(struct thread *td, struct file *fp, int *fd, int flags)
+{
+   struct filedesc *fdp = td-td_proc-p_fd;
+   int error;
+
+   KASSERT(fd != NULL, (%s: fd == NULL, __func__));
+   KASSERT(fp != NULL, (%s: fp == NULL, __func__));
+
+   FILEDESC_XLOCK(fdp);
+   if ((error = fdalloc(td, 0, fd))) {
+   FILEDESC_XUNLOCK(fdp);
return (error);
}
-   p-p_fd-fd_ofiles[i] = fp;
+   fhold(fp);
+   fdp-fd_ofiles[*fd] = fp;
if ((flags  O_CLOEXEC) != 0)
-   p-p_fd-fd_ofileflags[i] |= UF_EXCLOSE;
-   FILEDESC_XUNLOCK(p-p_fd);
-   if (resultfp)
-   *resultfp = fp;
-   if (resultfd)
-   *resultfd = i;
+   fdp-fd_ofileflags[*fd] |= UF_EXCLOSE;
+   FILEDESC_XUNLOCK(fdp);
return (0);
 }
 

Modified: head/sys/sys/filedesc.h
==
--- head/sys/sys/filedesc.h Thu Jun 30 14:10:49 2011(r223693)
+++ head/sys/sys/filedesc.h Thu Jun 30 15:22:49 2011(r223694)
@@ -113,6 +113,8 @@ int dupfdopen(struct thread *td, struct 
int mode, int error);
 intfalloc(struct thread *td, struct file **resultfp, int *resultfd,
int flags);
+intfalloc_noinstall(struct thread *td, struct file **resultfp);
+intfinstall(struct thread *td, struct file *fp, int *resultfp, int flags);
 intfdalloc(struct thread *td, 

svn commit: r223695 - in head/sys/boot: . common ficl/amd64 i386/libi386 userboot userboot/ficl userboot/libstand userboot/libstand/amd64 userboot/test userboot/userboot

2011-06-30 Thread Doug Rabson
Author: dfr
Date: Thu Jun 30 16:08:56 2011
New Revision: 223695
URL: http://svn.freebsd.org/changeset/base/223695

Log:
  Add a version of the FreeBSD bootloader which can run in userland, packaged
  as a shared library. This is intended to be used by BHyVe to load FreeBSD
  kernels into new virtual machines.

Added:
  head/sys/boot/common/disk.c   (contents, props changed)
  head/sys/boot/common/disk.h   (contents, props changed)
  head/sys/boot/ficl/amd64/
  head/sys/boot/ficl/amd64/sysdep.c   (contents, props changed)
  head/sys/boot/ficl/amd64/sysdep.h   (contents, props changed)
  head/sys/boot/userboot/
  head/sys/boot/userboot/Makefile   (contents, props changed)
  head/sys/boot/userboot/ficl/
  head/sys/boot/userboot/ficl/Makefile   (contents, props changed)
  head/sys/boot/userboot/libstand/
  head/sys/boot/userboot/libstand/Makefile   (contents, props changed)
  head/sys/boot/userboot/libstand/amd64/
  head/sys/boot/userboot/libstand/amd64/_setjmp.S   (contents, props changed)
  head/sys/boot/userboot/test/
  head/sys/boot/userboot/test/Makefile   (contents, props changed)
  head/sys/boot/userboot/test/test.c   (contents, props changed)
  head/sys/boot/userboot/userboot/
  head/sys/boot/userboot/userboot.h   (contents, props changed)
  head/sys/boot/userboot/userboot/Makefile   (contents, props changed)
  head/sys/boot/userboot/userboot/autoload.c   (contents, props changed)
  head/sys/boot/userboot/userboot/bootinfo.c   (contents, props changed)
  head/sys/boot/userboot/userboot/bootinfo32.c   (contents, props changed)
  head/sys/boot/userboot/userboot/bootinfo64.c   (contents, props changed)
  head/sys/boot/userboot/userboot/conf.c   (contents, props changed)
  head/sys/boot/userboot/userboot/copy.c   (contents, props changed)
  head/sys/boot/userboot/userboot/devicename.c   (contents, props changed)
  head/sys/boot/userboot/userboot/elf32_freebsd.c   (contents, props changed)
  head/sys/boot/userboot/userboot/elf64_freebsd.c   (contents, props changed)
  head/sys/boot/userboot/userboot/host.c   (contents, props changed)
  head/sys/boot/userboot/userboot/libuserboot.h   (contents, props changed)
  head/sys/boot/userboot/userboot/main.c   (contents, props changed)
  head/sys/boot/userboot/userboot/userboot_cons.c   (contents, props changed)
  head/sys/boot/userboot/userboot/userboot_disk.c   (contents, props changed)
  head/sys/boot/userboot/userboot/version   (contents, props changed)
Modified:
  head/sys/boot/Makefile.amd64
  head/sys/boot/common/Makefile.inc
  head/sys/boot/common/load_elf.c
  head/sys/boot/common/reloc_elf.c
  head/sys/boot/i386/libi386/bioscd.c

Modified: head/sys/boot/Makefile.amd64
==
--- head/sys/boot/Makefile.amd64Thu Jun 30 15:22:49 2011
(r223694)
+++ head/sys/boot/Makefile.amd64Thu Jun 30 16:08:56 2011
(r223695)
@@ -2,3 +2,4 @@
 
 SUBDIR+=   efi
 SUBDIR+=   zfs
+SUBDIR+=   userboot

Modified: head/sys/boot/common/Makefile.inc
==
--- head/sys/boot/common/Makefile.inc   Thu Jun 30 15:22:49 2011
(r223694)
+++ head/sys/boot/common/Makefile.inc   Thu Jun 30 16:08:56 2011
(r223695)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-SRCS+= boot.c commands.c console.c devopen.c interp.c 
+SRCS+= boot.c commands.c console.c devopen.c disk.c interp.c 
 SRCS+= interp_backslash.c interp_parse.c ls.c misc.c 
 SRCS+= module.c panic.c
 

Added: head/sys/boot/common/disk.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/boot/common/disk.c Thu Jun 30 16:08:56 2011(r223695)
@@ -0,0 +1,788 @@
+/*-
+ * Copyright (c) 1998 Michael Smith msm...@freebsd.org
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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 

svn commit: r223701 - head/contrib/sendmail/src

2011-06-30 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Jun 30 20:55:16 2011
New Revision: 223701
URL: http://svn.freebsd.org/changeset/base/223701

Log:
  Make Sendmail properly set login class and cpumask.

Modified:
  head/contrib/sendmail/src/deliver.c

Modified: head/contrib/sendmail/src/deliver.c
==
--- head/contrib/sendmail/src/deliver.c Thu Jun 30 20:34:55 2011
(r223700)
+++ head/contrib/sendmail/src/deliver.c Thu Jun 30 20:55:16 2011
(r223701)
@@ -2416,6 +2416,12 @@ tryhost:
else
pwd = sm_getpwnam(contextaddr-q_user);
sucflags = LOGIN_SETRESOURCES|LOGIN_SETPRIORITY;
+#ifdef LOGIN_SETCPUMASK
+   sucflags |= LOGIN_SETCPUMASK;
+#endif /* LOGIN_SETCPUMASK */
+#ifdef LOGIN_SETLOGINCLASS
+   sucflags |= LOGIN_SETLOGINCLASS;
+#endif /* LOGIN_SETLOGINCLASS */
 #ifdef LOGIN_SETMAC
sucflags |= LOGIN_SETMAC;
 #endif /* LOGIN_SETMAC */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r223702 - head/contrib/lukemftpd/src

2011-06-30 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Jun 30 20:58:38 2011
New Revision: 223702
URL: http://svn.freebsd.org/changeset/base/223702

Log:
  Make lukemftpd properly set login class and cpumask.

Modified:
  head/contrib/lukemftpd/src/ftpd.c

Modified: head/contrib/lukemftpd/src/ftpd.c
==
--- head/contrib/lukemftpd/src/ftpd.c   Thu Jun 30 20:55:16 2011
(r223701)
+++ head/contrib/lukemftpd/src/ftpd.c   Thu Jun 30 20:58:38 2011
(r223702)
@@ -1263,8 +1263,9 @@ end_login(void)
curclass.type = CLASS_REAL;
(void) seteuid((uid_t)0);
 #ifdef LOGIN_CAP
-   setusercontext(NULL, getpwuid(0), 0,
-  
LOGIN_SETPRIORITY|LOGIN_SETRESOURCES|LOGIN_SETUMASK|LOGIN_SETMAC);
+   setusercontext(NULL, getpwuid(0), 0, LOGIN_SETALL  ~(LOGIN_SETLOGIN |
+  LOGIN_SETUSER | LOGIN_SETGROUP | LOGIN_SETPATH |
+  LOGIN_SETENV));
 #endif
 #ifdef USE_PAM
if (pamh) {
@@ -1427,9 +1428,8 @@ pass(const char *passwd)
 #endif
}
setsid();
-   setusercontext(lc, pw, 0,
-   LOGIN_SETLOGIN|LOGIN_SETGROUP|LOGIN_SETPRIORITY|
-   LOGIN_SETRESOURCES|LOGIN_SETUMASK|LOGIN_SETMAC);
+   setusercontext(lc, pw, 0, LOGIN_SETALL 
+  ~(LOGIN_SETUSER | LOGIN_SETPATH | LOGIN_SETENV));
 #else
(void) initgroups(pw-pw_name, pw-pw_gid);
/* cache groups for cmds.c::matchgroup() */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r223666 - in head: sbin/ipfw sys/netinet sys/netinet/ipfw

2011-06-30 Thread Julian Elischer

On 6/29/11 3:06 AM, Andrey V. Elsukov wrote:

Author: ae
Date: Wed Jun 29 10:06:58 2011
New Revision: 223666
URL: http://svn.freebsd.org/changeset/base/223666

Log:
   Add new rule actions call and return to ipfw. They make
   possible to organize subroutines with rules.

   The call action saves the current rule number in the internal
   stack and rules processing continues from the first rule with
   specified number (similar to skipto action). If later a rule with
   return action is encountered, the processing returns to the first
   rule with number of call rule saved in the stack plus one or higher.

   Submitted by:Vadim Goncharov
   Discussed by:ipfw@, luigi@

Modified:

what happens if the return target is removed in the meanwhile?

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r223666 - in head: sbin/ipfw sys/netinet sys/netinet/ipfw

2011-06-30 Thread Luigi Rizzo
On Thu, Jun 30, 2011 at 10:14:44PM -0700, Julian Elischer wrote:
 On 6/29/11 3:06 AM, Andrey V. Elsukov wrote:
 Author: ae
 Date: Wed Jun 29 10:06:58 2011
 New Revision: 223666
 URL: http://svn.freebsd.org/changeset/base/223666
 
 Log:
Add new rule actions call and return to ipfw. They make
possible to organize subroutines with rules.
 
The call action saves the current rule number in the internal
stack and rules processing continues from the first rule with
specified number (similar to skipto action). If later a rule with
return action is encountered, the processing returns to the first
rule with number of call rule saved in the stack plus one or higher.
 
Submitted by: Vadim Goncharov
Discussed by: ipfw@, luigi@
 
 Modified:
 what happens if the return target is removed in the meanwhile?

i suppose it has the same vulnerability of skipto: if the target
goes away you continue from the next rule.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org