linux – 挂载CIFS共享失败:数值结果超出范围

前端之家收集整理的这篇文章主要介绍了linux – 挂载CIFS共享失败:数值结果超出范围前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在RHEL7中挂载cifs共享失败,并显示以下错误:“mount:无法解析挂载选项:数值结果超出范围”
# 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,uid=27,dir_mode=0775' user: '(null)',optstr: 'credentials=/etc/samba/fileserver.password,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

MysqL组存在:

# 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

如果发现有趣的是直接使用mount.cifs它正在工作:

# mount.cifs //fileserver/db-MysqL /mnt/MysqLBackups --verbose -o credentials=/etc/samba/fileserver.password,dir_mode=0775
Credential formatted incorrectly: (null)
domain=fileserver
mount.cifs kernel mount options: ip=10.1.2.20,unc=\\fileserver\db-MysqL,dir_mode=0775,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,addr=10.1.2.20,nounix,serverino,rsize=61440,wsize=65536,actimeo=1 0 0

它发生在:

# 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

同样的问题:

# 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和mount.cifs是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

似乎getgrnam_r(3)调用失败了.

编辑1:
我想使用用户名和组名而不是UID GID.我知道使用数字ID我可以解决问题.我知道删除gid = MysqL它会起作用.为什么用户mount能够找到UID,但是对于grup,它无法找到GID?

编辑2:
这段代码似乎抛出了这个错误
https://github.com/karelzak/util-linux/blob/master/libmount/src/utils.c#L703

所以我尝试使用以下代码重现,但调用成功.这对我来说很奇怪.对不起邋C的C代码,我不是程序员.

#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:

没有报告错误

# gcc -Wall -W test.c
# ./a.out
gid=27
#

编辑3:
如果我尝试gid = dbus它正在工作:

# 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,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,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,gid=dbsu' user: '(null)',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

解决方法

启用CIFS的系统无法将组名MysqL映射到GID 27,而是尝试将MysqL解析为数字GID值.这显然会超出范围,因为它是一个字符串而不是一个int.到目前为止,我还不清楚这是否是主机或客户端的失败.

如果化妆品组和用户名MysqL和附带的ID不在两台服务器上,则通过groupmod命令或编辑/ etc / group文件进行修复.如果所需的GID和UID在两台主机上相同,或者是固定的默认值(如MysqL,27为),则按编号指定GUID和UID,而不是按名称指定.这有点像kludge,但它可能会奏效.

有必要进一步调查为什么它没有将名称映射到ID的编号.自mount.cifs 1.10以来,我们已经能够使用装饰用户名和组名.再说一次,如果你没有在这个卷的平常挂载过程中调用mount.cifs帮助器,你可能永远不能使用化妆品名称,除非它在你正在使用的任何帮助器中显式实现.

猜你在找的Linux相关文章