Mounting a cifs share in RHEL7 fails with the following error: "mount: failed to parse mount options: Numerical result out of range"
# LIBMOUNT_DEBUG=0xffff mount //fileserver/db-mysql /mnt/mysqlBackups -t cifs -o credentials=/etc/samba/fileserver.password,forceuid,uid=mysql,forcegid,gid=mysql,file_mode=0664,dir_mode=0775 -v
5561: libmount: INIT: library debug mask: 0xffff
5561: libmount: INIT: library version: 2.23.0
5561: libmount: INIT: feature: selinux
5561: libmount: INIT: feature: debug
5561: libmount: INIT: feature: assert
5561: libmount: CXT: [0x7ff506842050]: ----> allocate
5561: libmount: UTILS: mtab: /etc/mtab
5561: libmount: UTILS: /etc/mtab: irregular/non-writable
5561: libmount: UTILS: utab: /run/mount/utab
5561: libmount: CXT: [0x7ff506842050]: enabling flag 0010
5561: libmount: CXT: [0x7ff506842050]: mount: preparing
5561: libmount: CXT: [0x7ff506842050]: use default optmode
5561: libmount: CXT: [0x7ff506842050]: OPTSMODE: ignore=0, append=0, prepend=1, replace=0, force=0, fstab=1, mtab=1
5561: libmount: CXT: [0x7ff506842050]: fstab not required -- skip
5561: libmount: CXT: [0x7ff506842050]: merging mount flags
5561: libmount: CXT: [0x7ff506842050]: final flags: VFS=00000000 user=00000000
5561: libmount: CXT: [0x7ff506842050]: mount: evaluating permissions
5561: libmount: CXT: [0x7ff506842050]: mount: fixing optstr
5561: libmount: CXT: [0x7ff506842050]: mount: fixing vfs optstr
5561: libmount: CXT: applying 0x00000000 flags to '(null)'
5561: libmount: CXT: new optstr 'rw'
5561: libmount: CXT: [0x7ff506842050]: mount: fixing user optstr
5561: libmount: CXT: applying 0x00000000 flags to '(null)'
5561: libmount: CXT: new optstr '(null)'
5561: libmount: CXT: fixing uid
5561: libmount: CXT: fixing gid
5561: libmount: UTILS: cannot convert 'mysql' groupname to GID
5561: libmount: CXT: [0x7ff506842050]: fixed options [rc=-34]: vfs: 'rw' fs: 'credentials=/etc/samba/fileserver.password,forceuid,uid=27,forcegid,gid=mysql,file_mode=0664,dir_mode=0775' user: '(null)', optstr: 'credentials=/etc/samba/fileserver.password,forceuid,uid=mysql,forcegid,gid=mysql,file_mode=0664,dir_mode=0775'
5561: libmount: CXT: [0x7ff506842050]: mount: preparing failed
mount: failed to parse mount options: Numerical result out of range
5561: libmount: CXT: [0x7ff506842050]: <---- reset [status=0] ---->
5561: libmount: CXT: [0x7ff506842050]: tabfiler disabled
5561: libmount: CXT: [0x7ff506842050]: <---- free
The mysql group exists:
# getent group mysql
mysql:x:27:
# grep mysql /etc/group
mysql:x:27:
# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
# ls -lZ /etc/group /etc/passwd
-rw-r--r--. root root system_u:object_r:passwd_file_t:s0 /etc/group
-rw-r--r--. root root system_u:object_r:passwd_file_t:s0 /etc/passwd
What if found interesting is that using directly mount.cifs
it is working:
# mount.cifs //fileserver/db-mysql /mnt/mysqlBackups --verbose -o credentials=/etc/samba/fileserver.password,forceuid,uid=mysql,forcegid,gid=mysql,file_mode=0664,dir_mode=0775
Credential formatted incorrectly: (null)
domain=fileserver
mount.cifs kernel mount options: ip=10.1.2.20,unc=\\fileserver\db-mysql,forceuid,forcegid,file_mode=0664,dir_mode=0775,uid=27,gid=27,user=svc_linux,,domain=fileserver,pass=********
# grep /mnt/mysqlBackups /proc/mounts
//fileserver/db-mysql /mnt/mysqlBackups cifs rw,relatime,vers=1.0,cache=strict,username=svc_linux,domain=fileserver,uid=27,forceuid,gid=27,forcegid,addr=10.1.2.20,file_mode=0664,dir_mode=0775,nounix,serverino,rsize=61440,wsize=65536,actimeo=1 0 0
It happens in:
# uname -rvpio
3.10.0-327.36.1.el7.x86_64 #1 SMP Sun Sep 18 13:04:29 UTC 2016 x86_64 x86_64 GNU/Linux
Same problem in:
# uname -rvpio
3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 GNU/Linux
mount and mount.cifs are the latest version for RHEL7:
# rpm -q util-linux cifs-utils
util-linux-2.23.2-26.el7_2.3.x86_64
cifs-utils-6.2-7.el7.x86_64
It seems that getgrnam_r(3)
call fails.
Edit 1:
I want to use user and group names and not UID GID. I know that useing numerical IDs I can solve the problem. I know that removing gid=mysql
it will work. Why for user mount is able to find UID, but for grup it fails to find GID?
Edit 2: The error seems to be thrown by this code: https://github.com/karelzak/util-linux/blob/master/libmount/src/utils.c#L703
So I tried to reproduce with the following code, but the call is successful. Which is very strange for me. Sorry for the sloppy C code, I am not a programmer.
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <grp.h>
#define UL_GETPW_BUFSIZ (16 * 1024)
int main(void)
{
int rc = -1;
struct group grp;
struct group *gr;
char *buf;
int _gid=10;
gid_t *gid = (gid_t *)& _gid;
char *groupname = "mysql";
if (!groupname || !gid)
return -EINVAL;
buf = malloc(UL_GETPW_BUFSIZ);
if (!buf)
return -ENOMEM;
if (!getgrnam_r(groupname, &grp, buf, UL_GETPW_BUFSIZ, &gr) && gr) {
*gid= gr->gr_gid;
printf("gid=%i\n",*gid);
rc = 0;
} else {
printf("cannot convert '%s' groupname to GID\n", groupname);
rc = errno ? -errno : -EINVAL;
}
free(buf);
return rc;
}
// vim:ts=4:sts=4:sw=4:et:
No errors are reported:
# gcc -Wall -W test.c
# ./a.out
gid=27
#
Edit 3:
If I try with gid=dbus
it is working:
# egrep 'mysql|dbus' /etc/passwd /etc/shadow /etc/group /etc/gshadow
/etc/passwd:dbus:x:81:81:System message bus:/:/sbin/nologin
/etc/passwd:mysql:x:27:27:Percona Server:/var/lib/mysql:/bin/false
/etc/shadow:dbus:!!:17086::::::
/etc/shadow:mysql:!!:17104::::::
/etc/group:dbus:x:81:
/etc/group:mysql:x:27:
/etc/gshadow:dbus:!::
/etc/gshadow:mysql:!::
# LIBMOUNT_DEBUG=0xffff mount //fileserver/db-mysql /mnt/mysqlBackups -t cifs -o credentials=/etc/samba/fileserver.password,forceuid,uid=mysql,forcegid,file_mode=0664,dir_mode=0775,gid=dbsu
10777: libmount: INIT: library debug mask: 0xffff
10777: libmount: INIT: library version: 2.23.0
10777: libmount: INIT: feature: selinux
10777: libmount: INIT: feature: debug
10777: libmount: INIT: feature: assert
10777: libmount: CXT: [0x7f687bf74050]: ----> allocate
10777: libmount: UTILS: mtab: /etc/mtab
10777: libmount: UTILS: /etc/mtab: irregular/non-writable
10777: libmount: UTILS: utab: /run/mount/utab
10777: libmount: CXT: [0x7f687bf74050]: mount: preparing
10777: libmount: CXT: [0x7f687bf74050]: use default optmode
10777: libmount: CXT: [0x7f687bf74050]: OPTSMODE: ignore=0, append=0, prepend=1, replace=0, force=0, fstab=1, mtab=1
10777: libmount: CXT: [0x7f687bf74050]: fstab not required -- skip
10777: libmount: CXT: [0x7f687bf74050]: merging mount flags
10777: libmount: CXT: [0x7f687bf74050]: final flags: VFS=00000000 user=00000000
10777: libmount: CXT: [0x7f687bf74050]: mount: evaluating permissions
10777: libmount: CXT: [0x7f687bf74050]: mount: fixing optstr
10777: libmount: CXT: [0x7f687bf74050]: mount: fixing vfs optstr
10777: libmount: CXT: applying 0x00000000 flags to '(null)'
10777: libmount: CXT: new optstr 'rw'
10777: libmount: CXT: [0x7f687bf74050]: mount: fixing user optstr
10777: libmount: CXT: applying 0x00000000 flags to '(null)'
10777: libmount: CXT: new optstr '(null)'
10777: libmount: CXT: fixing uid
10777: libmount: CXT: fixing gid
10777: libmount: UTILS: cannot convert 'dbsu' groupname to GID
10777: libmount: CXT: [0x7f687bf74050]: fixed options [rc=-34]: vfs: 'rw' fs: 'credentials=/etc/samba/fileserver.password,forceuid,uid=27,forcegid,file_mode=0664,dir_mode=0775,gid=dbsu' user: '(null)', optstr: 'credentials=/etc/samba/fileserver.password,forceuid,uid=mysql,forcegid,file_mode=0664,dir_mode=0775,gid=dbsu'
10777: libmount: CXT: [0x7f687bf74050]: mount: preparing failed
mount: failed to parse mount options: Numerical result out of range
10777: libmount: CXT: [0x7f687bf74050]: <---- reset [status=0] ---->
10777: libmount: CXT: [0x7f687bf74050]: tabfiler disabled
10777: libmount: CXT: [0x7f687bf74050]: <---- free
Your CIFS enabled system can't map the group name
mysql
to GID27
, and instead tries to parsemysql
as a numerical GID value. This is obviously going to be out of range, because it's a string rather than an int. It's unclear to me as of yet whether this is a failing on the host or client side.If the cosmetic group and user name
mysql
and accompanying ID isn't on both servers, then fix that via thegroupmod
command or via editing the/etc/group
file. If the GID and UID desired is the same on both hosts, or a fixed default (likemysql
,27
is), then specify the GUID and UID by number, not by name. That's a bit of a kludge, but it will probably work.Further investigation as to why it's failing to map name to number for IDs is warranted. We've been able to use cosmetic user and group names since mount.cifs 1.10. Then again, if you aren't invoking the mount.cifs helper in your usual mount process for this volume, you probably won't ever be able to use cosmetic names unless it's explicitly implemented in whatever helper you're using instead.