A montagem de um compartilhamento cifs no RHEL7 falha com o seguinte erro: "mount: falha ao analisar as opções de montagem: resultado numérico fora do intervalo"
# 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
O grupo mysql existe:
# 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
O que se achou interessante é que usando diretamente mount.cifs
está funcionando:
# 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
Isso acontece em:
# 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
O mesmo problema em:
# 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 e mount.cifs são a versão mais recente do 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
Parece que a chamada getgrnam_r(3)
falha.
Editar 1:
Eu quero usar nomes de usuário e grupo e não UID GID. Eu sei que usando IDs numéricos eu posso resolver o problema. Eu sei que remover gid=mysql
vai funcionar. Por que a montagem do usuário é capaz de encontrar o UID, mas, para o grup, ele não consegue encontrar o GID?
Editar 2:
O erro parece ser lançado por este código:
link
Então eu tentei reproduzir com o seguinte código, mas a chamada foi bem sucedida. O que é muito estranho para mim. Desculpe pelo código C desleixado, não sou programador.
#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:
Nenhum erro é relatado:
# gcc -Wall -W test.c
# ./a.out
gid=27
#
Editar 3:
Se eu tentar com gid=dbus
, está funcionando:
# 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