LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 899|回复: 0

【求助】关于mount, umount函数调用权限的问题

[复制链接]
发表于 2009-3-26 16:51:02 | 显示全部楼层 |阅读模式
struct __user_cap_header_struct hdrp;
    struct __user_cap_data_struct datap;

    hdrp.pid = getpid();
    hdrp.version = _LINUX_CAPABILITY_VERSION;
    ret = capget(&hdrp, &datap);
    if (0 != ret)
        perror("capget");

    datap.effective = 1 << CAP_SYS_ADMIN;
    datap.permitted = 1 << CAP_SYS_ADMIN;
    datap.inheritable = 0;
    ret = capset(&hdrp, &datap);
    if (0 != ret)
        perror("capset");

     // call mount with CAP_SYS_ADMIN
     mount(server, target, "nfs", 0, NULL);

因为mount函数需要CAP_SYS_ADMIN权限,所以我尝试这样修改,
在capset的时候,返回错误信息为
Operation not permitted

请问大家该如何解决,或者解释一下如何调用mount,谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表