Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 549238 - app-shells/bash: `ulimit` in man page should mention POSIX mode block size differences
Summary: app-shells/bash: `ulimit` in man page should mention POSIX mode block size di...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://lists.gnu.org/archive/html/bu...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-12 07:28 UTC by Agostino Sarubbo
Modified: 2015-06-05 11:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2015-05-12 07:28:13 UTC
I need to setup a samba server which can't accept files bigger than 200MB.

The right way is add rc_ulimit="-f 204800" in /etc/conf.d/samba


The result is that I can't upload file bigger that 100MB (the half of what I declared)

So, a workaround for me is set 409600 so the half is 204800 but I think it is very odd.


Also, if I'm doing: ulimit -f 204800 ; /etc/init.d/samba start it works as expected and the limit is 200MB.


Portage 2.2.18 (python 2.7.9-final-0, default/linux/amd64/13.0, gcc-4.8.4, glibc-2.20-r2, 3.14.37-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.14.37-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5310_@_1.60GHz-with-gentoo-2.2
KiB Mem:     8173800 total,   5407400 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Mon, 04 May 2015 06:00:01 +0000
sh bash 4.2_p53
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.2_p53::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.9-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.13.11::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.13.4::gentoo
sys-devel/binutils:       2.24-r3::gentoo
sys-devel/gcc:            4.8.4::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo                                                                                                                                                                                                                                       
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)                                                                                                                                                                                                                    
sys-libs/glibc:           2.20-r2::gentoo                                                                                                                                                                                                                                      
Repositories:                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                               
gentoo                                                                                                                                                                                                                                                                         
    location: /usr/portage                                                                                                                                                                                                                                                     
    sync-type: rsync                                                                                                                                                                                                                                                           
    sync-uri: rsync://192.168.0.22/gentoo-portage                                                                                                                                                                                                                              
    priority: -1000                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                               
ACCEPT_KEYWORDS="amd64"                                                                                                                                                                                                                                                        
ACCEPT_LICENSE="*"                                                                                                                                                                                                                                                             
CBUILD="x86_64-pc-linux-gnu"                                                                                                                                                                                                                                                   
CFLAGS="-O2 -march=x86-64 -fno-stack-protector"                                                                                                                                                                                                                                
CHOST="x86_64-pc-linux-gnu"                                                                                                                                                                                                                                                    
CONFIG_PROTECT="/etc"                                                                                                                                                                                                                                                          
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"                                                                                                                                     
CXXFLAGS="-O2 -march=x86-64 -fno-stack-protector"                                                                                                                                                                                                                              
DISTDIR="/usr/portage/distfiles"                                                                                                                                                                                                                                               
EMERGE_DEFAULT_OPTS="--with-bdeps y -b"                                                                                                                                                                                                                                        
FCFLAGS="-O2 -pipe"                                                                                                                                                                                                                                                            
FEATURES="assume-digests binpkg-logs buildpkg collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"                                                                                                                                                                                                                                    
FFLAGS="-O2 -pipe"                                                                                                                                                                                                                                                             
GENTOO_MIRRORS="http://192.168.0.22/ http://distfiles.gentoo.org http://gentoo.wheel.sk/ http://mirror.netcologne.de/gentoo/ http://mirrors.linuxant.fr/distfiles.gentoo.org/"                                                                                                 
LANG="it_IT.UTF-8"                                                                                                                                                                                                                                                             
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-z,lazy"                                                                                                                                                                                                             
MAKEOPTS="-j4"                                                                                                                                                                                                                                                                 
PKGDIR="/usr/portage/packages"                                                                                                                                                                                                                                                 
PORTAGE_CONFIGROOT="/"                                                                                                                                                                                                                                                         
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"                                               
PORTAGE_TMPDIR="/tmp/"                                                                                                                                                                                                                                                         
USE="acl amd64 berkdb bzip2 cli cracklib crypt cxx dri fortran gdbm iconv mmx mmxext modules multilib ncurses nptl openmp pam pcre readline session sse sse2 ssl tcpd unicode zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_GB" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU"                                                                             
USE_PYTHON="2.7"                                                                                                                                                                                                                                                               
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS                                                                                                                                   
                                                                                                                                                                                                                                                                               
=================================================================                                                                                                                                                                                                              
                        Package Settings                                                                                                                                                                                                                                       
=================================================================                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                               
sys-apps/openrc-0.13.11::gentoo was built with the following:                                                                                                                                                                                                                  
USE="ncurses netifrc pam unicode -debug -newnet (-prefix) (-selinux) -static-libs -tools" ABI_X86="64"
Comment 1 William Hubbs gentoo-dev 2015-05-12 18:50:34 UTC
@base-system:
Can you advise me on this one?

Thanks,

William
Comment 2 William Hubbs gentoo-dev 2015-05-12 18:52:52 UTC
@samba:
Can you also take a look and advise me?

Thanks,

William
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2015-05-15 15:59:26 UTC
I don't think the problem originates in openrc.
runscript.sh, which handles the rc_ulimit variable, simply calls the shell primitive

It's also not limited to samba, I added rc_ulimit='-f 16' (so a 16KB limit) to fakeidentd, which is an extremely simple program (~500 lines of C, does nothing to limits itself); and here is the result:
# grep file /proc/`pidof fakeidentd`/limits
Max file size             8192                 8192                 bytes     
Max core file size        0                    unlimited            bytes     
Max open files            1024                 4096                 files     
Max file locks            unlimited            unlimited            lock

My bet is on bash or libc, but I need to confirm this still.

The help for bash describes how most limits are actually 1k multiples (except for one that is a 512-byte multiple, and some that are singular).
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2015-05-15 18:14:25 UTC
Solved it!

We're in POSIX bash mode, and block size is defined as 512-byte, not 1K.

The help output and manpage for Bash don't explicitly say, but they do reference this document, that covers it:
http://tiswww.case.edu/php/chet/bash/POSIX
 48. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
     and `-f' options.

Since OpenRC is used with dash and other posix-correct shells, I think the actions taken should be:
1. Amend the bash help & manpage to mention the blocksize variation on mode.
2. Add a comment to rc.conf about it as well.
Comment 5 William Hubbs gentoo-dev 2015-05-22 15:31:31 UTC
In OpenRC, I added a note about this in commit bbabf54 which will be
part of OpenRC-0.17.
Comment 6 William Hubbs gentoo-dev 2015-06-04 17:24:24 UTC
All,

this has been documented in OpenRC-0.16.4, so I am assigning to
base-system since the other suggestion Robin made is to modify the bash
help.

Thanks,

William
Comment 7 SpanKY gentoo-dev 2015-06-05 11:22:45 UTC
sent the patch upstream:
https://lists.gnu.org/archive/html/bug-bash/2015-06/msg00020.html