Bug 14946 - set_maxfiles: setrlimit for RLIMIT_NOFILE for 16424 files failed with error Invalid argument
Summary: set_maxfiles: setrlimit for RLIMIT_NOFILE for 16424 files failed with error I...
Status: RESOLVED INVALID
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.15.3
Hardware: All Mac OS X
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-13 16:15 UTC by Bjarne D Mathiesen
Modified: 2022-01-13 18:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bjarne D Mathiesen 2022-01-13 16:15:57 UTC
#=> system_profiler SPHardwareDataType SPSoftwareDataType
 Hardware:
       Model Name: Mac mini
       Model Identifier: Macmini2,1
       Processor Name: Intel Core 2 Duo
 Software:
       System Version: Mac OS X 10.6.8 (10K549)
       Kernel Version: Darwin 10.8.0

So, I've got samba 4.15.3 to compile & install

Now, when I'm trying to run it I get :

smbd version 4.15.3 started.
 Copyright Andrew Tridgell and the Samba Team 1992-2021
 INFO: Profiling support unavailable in this build.
 daemon_status: daemon 'smbd' : Starting process ...
 tdbsam_open: Converting version 0.0 database to version 4.0.
 tdbsam_convert_backup: updated /opt/local/var/lib/samba/private/secrets.tdb file.
 set_maxfiles: setrlimit for RLIMIT_NOFILE for 16424 files failed with error Invalid argument

 Terminated

When I search the source for this, I get :

#=> grep -Rn RLIMIT_NOFILE *
 python/samba/netcmd/user.py:2674:            maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
 script/autobuild.py:1408:    maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
 source3/lib/util.c:1279:#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
 source3/lib/util.c:1283:        if(getrlimit(RLIMIT_NOFILE, &rlp)) {
 source3/lib/util.c:1284:                DEBUG(0,("set_maxfiles: getrlimit (1) for RLIMIT_NOFILE failed with error %s\n",
 source3/lib/util.c:1311:                if(setrlimit(RLIMIT_NOFILE, &rlp)) {
 source3/lib/util.c:1312:                        DEBUG(3,("set_maxfiles: setrlimit for RLIMIT_NOFILE for %d max files failed with error %s\n",
 source3/lib/util.c:1325:        if(setrlimit(RLIMIT_NOFILE, &rlp)) {
 source3/lib/util.c:1326:                DEBUG(0,("set_maxfiles: setrlimit for RLIMIT_NOFILE for %d files failed with error %s\n",
 source3/lib/util.c:1332:        if(getrlimit(RLIMIT_NOFILE, &rlp)) {
 source3/lib/util.c:1333:                DEBUG(0,("set_maxfiles: getrlimit (2) for RLIMIT_NOFILE failed with error %s\n",
 source3/lib/util.c:1348:#else /* !defined(HAVE_GETRLIMIT) || !defined(RLIMIT_NOFILE) */
 source3/param/loadparm.c:301:#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
 source3/param/loadparm.c:307:           if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
 source4/heimdal/lib/roken/getdtablesize.c:71:#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
 source4/heimdal/lib/roken/getdtablesize.c:73:  if (getrlimit(RLIMIT_NOFILE, &res) == 0)

 So, it looks as if it's {{{source3/lib/util.c:1326}}} that's the issue

 Any ideas as to how I can fix this ?!?

Comment (by jmroot):

 Setting RLIMIT_NOFILE to a value greater than OPEN_MAX will fail. So
the value passed to setrlimit needs to be capped at OPEN_MAX.

https://trac.macports.org/ticket/64403
https://trac.macports.org/ticket/64396
Comment 1 Bjarne D Mathiesen 2022-01-13 18:23:16 UTC
smbd started with :

#=> smbd \
    --foreground \
    --configfile=/opt/local/etc/samba4/smb.conf \
    --interactive
Comment 2 Bjarne D Mathiesen 2022-01-13 18:48:49 UTC
please close as invalid
the problem was something entirely else : 
https://bugzilla.samba.org/show_bug.cgi?id=11897