conffile: use /usr/etc aswell
Subsystems (2)
cover conffile: use /usr/etc aswell
The first patch it just a little cleanup.
The second is the important one. It follows a trend of deprecating / in favour of /usr
NeilBrown
[PATCH 1/2] conffile: don't report error from conf_init_file() [PATCH 2/2] conffile: allow /usr/etc to provide any config files
PATCH 1/2 conffile: don't report error from conf_init_file()
conf_init_file() currently reports an error if the main config file doesn't exist - even if there are conf files in the conf.d directory.
This is only used by nfsconfcli.c. However this is not needed. If there is a real error, and error message is already logged. If it is simply that the file doesn't exist, that isn't really an error.
So remove the error messages and change conf_init_file() to not return any status.
Also fix up assorted nearby white-space issues.
--- support/include/conffile.h | 2 +- support/nfs/conffile.c | 32 ++++++++++++++------------------ tools/nfsconf/nfsconfcli.c | 15 ++------------- 3 files changed, 17 insertions(+), 32 deletions(-)
support/include/conffile.h +1 -1
@@ -62,7 +62,7 @@ extern char *conf_get_str(const char *, const char *);extern char *conf_get_str_with_def (const char *,const char *,char *);extern char *conf_get_section (const char *,const char *,const char *);extern char *conf_get_entry (const char *,const char *,const char *); -extern int conf_init_file (const char *); +extern void conf_init_file (const char *);extern void conf_cleanup (void );extern int conf_match_num (const char *,const char *,int );extern int conf_remove (int ,const char *,const char *);
support/nfs/conffile.c +14 -18
@@ -658,7 +658,7 @@ conf_load_file(const char *conf_file)return 0 ; } -static void +static void conf_init_dir (const char *conf_file) {struct dirent **namelist =NULL ;
@@ -669,14 +669,14 @@ conf_init_dir(const char *conf_file) dname =malloc (strlen (conf_file) +3 );if (dname ==NULL ) {xlog (L_WARNING ,"conf_init_dir: malloc: %s" ,strerror (errno)); -return ; +return ; }sprintf (dname,"%s.d" , conf_file); n =scandir (dname, &namelist,NULL , versionsort);if (n <0 ) {if (errno !=ENOENT ) { -xlog (L_WARNING ,"conf_init_dir: scandir %s: %s" , +xlog (L_WARNING ,"conf_init_dir: scandir %s: %s" , dname,strerror (errno)); }free (dname);
@@ -691,7 +691,7 @@ conf_init_dir(const char *conf_file)for (i =0 ; i < n; i++ ) {struct dirent *d = namelist[i]; -switch (d->d_type) { +switch (d->d_type) {case DT_UNKNOWN :case DT_REG :case DT_LNK :
@@ -701,13 +701,13 @@ conf_init_dir(const char *conf_file) }if (*d->d_name =='.' )continue ; - + fname_len =strlen (d->d_name); path_len = (fname_len + dname_len);if (!fname_len || path_len >PATH_MAX ) {xlog (L_WARNING ,"conf_init_dir: Too long file name: %s in %s" , d->d_name, dname); -continue ; +continue ; }/*
@@ -715,7 +715,7 @@ conf_init_dir(const char *conf_file)* that end with CONF_FILE_EXT */ if (fname_len <=CONF_FILE_EXT_LEN ) { -xlog (D_GENERAL ,"conf_init_dir: %s: name too short" , +xlog (D_GENERAL ,"conf_init_dir: %s: name too short" , d->d_name);continue ; }
@@ -746,31 +746,29 @@ conf_init_dir(const char *conf_file)free (namelist[i]);free (namelist);free (dname); - +return ; } -int +void conf_init_file (const char *conf_file) {unsigned int i; -int ret;for (i =0 ; i <sizeof conf_bindings /sizeof conf_bindings[0 ]; i++)LIST_INIT (&conf_bindings[i]);TAILQ_INIT (&conf_trans_queue); -if (conf_file ==NULL ) - conf_file=NFS_CONFFILE ; +if (conf_file ==NULL ) + conf_file =NFS_CONFFILE ;/* -* First parse the give config file -* then parse the config.conf.d directory +* First parse the give config file +* then parse the config.conf.d directory * (if it exists) -* */ - ret =conf_load_file (conf_file); +conf_load_file (conf_file);/* * When the same variable is set in both files
@@ -779,8 +777,6 @@ conf_init_file(const char *conf_file)* have the final say. */ conf_init_dir (conf_file); - -return ret; }/*
tools/nfsconf/nfsconfcli.c +2 -13
@@ -135,19 +135,8 @@ int main(int argc, char **argv)return 1 ; } -if (mode !=MODE_SET && mode !=MODE_UNSET ) { -if (conf_init_file (confpath)) { -/* config file was missing or had an error, warn about it */ -if (verbose || mode !=MODE_ISSET ) { -fprintf (stderr,"Error loading config file %s\n" , - confpath); - } - -/* this isnt fatal for --isset */ -if (mode !=MODE_ISSET ) -return 1 ; - } - } +if (mode !=MODE_SET && mode !=MODE_UNSET ) +conf_init_file (confpath);/* --dump mode, output the current configuration */ if (mode ==MODE_DUMP ) {
Signature · 1 line
2.42.0
PATCH 2/2 conffile: allow /usr/etc to provide any config files expected in /etc
In reply to NeilBrownIf any config file is configured to be in /etc, also read from /usr/etc. This followed a growing trend of moving as much as possible out of / and into /usr.
See https://en.opensuse.org/openSUSE:Packaging_UsrEtc
--- support/nfs/conffile.c | 27 ++++++++++++++++----------- support/nfsidmap/idmapd.conf.5 | 15 ++++++++++++++- systemd/nfs.conf.man | 23 ++++++++++++++--------- systemd/nfs.systemd.man | 10 +++++++++- utils/mount/nfsmount.conf.man | 19 ++++++++++--------- 5 files changed, 63 insertions(+), 31 deletions(-)
support/nfs/conffile.c +16 -11
@@ -763,19 +763,24 @@ conf_init_file(const char *conf_file)if (conf_file ==NULL ) conf_file =NFS_CONFFILE ; -/* -* First parse the give config file -* then parse the config.conf.d directory -* (if it exists) +/* If the config file is in /etc (normal) then check +* /usr/etc first. Also check config.conf.d for files +* names *.conf. +* +* Content or later files always over-rides earlier +* files. */ +if (strncmp (conf_file,"/etc/" ,5 ) ==0 ) { +char *usrconf =NULL ; + +asprintf (&usrconf,"/usr%s" , conf_file); +if (usrconf) { +conf_load_file (usrconf); +conf_init_dir (usrconf); +free (usrconf); + } + }conf_load_file (conf_file); - -/* -* When the same variable is set in both files -* the conf.d file will override the config file. -* This allows automated admin systems to -* have the final say. -*/ conf_init_dir (conf_file); }
support/nfsidmap/idmapd.conf.5 +14 -1
@@ -37,7 +37,7 @@ Configuration file for libnfsidmap. Used by idmapd and svcgssd to map NFSv4 nam .SH DESCRIPTION The .B idmapd.conf -configuration file consists of several sections, initiated by strings of the +configuration files consists of several sections, initiated by strings of the form [General] and [Mapping]. Each section may contain lines of the form .nf variable = value
@@ -398,6 +398,19 @@ LDAP_base = dc=org,dc=domain .\" Additional sections .\" ------------------------------------------------------------------- .\" +.SH FILES +.I /usr/etc/idmapd.conf +.br +.I /usr/etc/idmapd.conf.d/*.conf +.br +.I /etc/idmapd.conf +.br +.I /etc/idmapd.conf.d/*.conf +.br +.IP +Files are read in the order listed. Later settings override earlier +settings. + .SH SEE ALSO .BR idmapd (8) .BR svcgssd (8)
systemd/nfs.conf.man +14 -9
@@ -2,10 +2,13 @@ .SH NAME nfs.conf \- general configuration for NFS daemons and tools .SH SYNOPSIS +.I /usr/etc/nfs.conf +.I /usr/etc/nfs.conf.d/ .I /etc/nfs.conf +.I /etc/nfs.conf.d/ .SH DESCRIPTION .PP -This file contains site-specific configuration for various NFS daemons +These files contain site-specific configuration for various NFS daemons and other processes. Most configuration can also be passed to processes via command line arguments, but it can be more convenient to have a central file. In particular, this encourages consistent
@@ -314,15 +317,17 @@ See for deatils. .SH FILES -.TP 10n +.I /usr/etc/nfs.conf +.br +.I /usr/etc/nfs.conf.d/*.conf +.br .I /etc/nfs.conf -Default NFS client configuration file -.TP 10n -.I /etc/nfs.conf.d -When this directory exists and files ending -with ".conf" exist, those files will be -used to set configuration variables. These -files will override variables set in /etc/nfs.conf +.br +.I /etc/nfs.conf.d/*.conf +.br +.IP +Various configuration files read in order. Later settings override +earlier settings. .SH SEE ALSO .BR nfsdcltrack (8), .BR rpc.nfsd (8),
systemd/nfs.systemd.man +9 -1
@@ -27,7 +27,9 @@ any command line arguments to daemons so as to configure their behavior. In many case such configuration can be performed by making changes to .I /etc/nfs.conf -or other configuration files. When that is not convenient, a +or other configuration files (see +.BR nfs.conf (5)). +When that is not convenient, a distribution might provide systemd "drop-in" files which replace the .B ExecStart= setting to start the program with different arguments. For example a
@@ -171,6 +173,12 @@ running, it can be masked with /etc/nfsmount.conf .br /etc/idmapd.conf +.P +Also similar files in +.B /usr/etc +and in related +.I conf.d +drop-in directories. .SH SEE ALSO .BR systemd.unit (5), .BR nfs.conf (5),
utils/mount/nfsmount.conf.man +10 -9
@@ -115,16 +115,17 @@ All mounts to the '/export/home' export will be performed in the background (i.e. done asynchronously). .RE .SH FILES -.TP 10n +.I /usr/etc/nfsmount.conf +.br +.I /usr/etc/nfsmount.conf.d/*.conf +.br .I /etc/nfsmount.conf -Default NFS mount configuration file -.TP 10n -.I /etc/nfsmount.conf.d -When this directory exists and files ending -with ".conf" exist, those files will be -used to set configuration variables. These -files will override variables set -in /etc/nfsmount.conf +.br +.I /etc/nfsmount.conf.d/*.conf +.br +.IP +Default NFS mount configuration files, variables set in the later file +over-ride those in the earlier file. .PD .SH SEE ALSO .BR nfs (5),
Signature · 1 line
2.42.0
Quoted 8 lines · NeilBrown
The first patch it just a little cleanup.
The second is the important one. It follows a trend of deprecating / in favour of /usrNeilBrown
[PATCH 1/2] conffile: don't report error from
conf_init_file()[PATCH 2/2] conffile: allow/usr/etcto provide any config files
Committed... (tag: nfs-utils-2-7-1-rc1)
steved