'Differnece between cap_set_flag and capset

I am using the linux capabilities by cap_set_flag.

It's published like , capabilities of the process would be reflected in /proc/$$/task/$$/status

But with cap_set_flag, it won't reflect . Only with capset API ,the capabilities are getting recorded in this status file.

Any reason for this.

Does this depend on kernel version which I am using (4.19.183).

I tried using cap_set_flag as below

cap_list[0] = CAP_CHOWN;
if (cap_set_flag(cap, CAP_EFFECTIVE, 1, cap_list, CAP_SET) == -1) {
    perror("cap_set_flag cap_chown");
    cap_free(cap);
    exit(-1);
}  

want this to be reflected in status file

$ grep Cap /proc/$$/task/$$/status
CapInh: 00000000a80425fb
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 00000000a80425fb
CapAmb: 0000000000000000


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source