|
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,谢谢! |
|