New API call iso_util_get_effective_lfa_mask()
This commit is contained in:
parent
d717613c93
commit
443743d2d8
@ -1003,10 +1003,8 @@ int iso_local_set_lfa_flags(char *disk_path, uint64_t lfa_flags, int max_bit,
|
|||||||
{
|
{
|
||||||
int ret, old_max_bit;
|
int ret, old_max_bit;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
uint64_t known_user_mask, known_su_mask, non_settable, unknown, eff_flags;
|
uint64_t eff_flags;
|
||||||
|
|
||||||
iso_util_get_lfa_masks(&known_user_mask, &known_su_mask, &non_settable,
|
|
||||||
&unknown);
|
|
||||||
*os_errno = 0;
|
*os_errno = 0;
|
||||||
if (flag & 32)
|
if (flag & 32)
|
||||||
ret = stat(disk_path, &stbuf);
|
ret = stat(disk_path, &stbuf);
|
||||||
@ -1018,10 +1016,7 @@ int iso_local_set_lfa_flags(char *disk_path, uint64_t lfa_flags, int max_bit,
|
|||||||
}
|
}
|
||||||
if ((stbuf.st_mode & S_IFMT) == S_IFLNK && !(flag & 32))
|
if ((stbuf.st_mode & S_IFMT) == S_IFLNK && !(flag & 32))
|
||||||
return 3;
|
return 3;
|
||||||
if (flag & 1)
|
change_mask= iso_util_get_effective_lfa_mask(change_mask, flag & 3);
|
||||||
change_mask &= ~known_su_mask;
|
|
||||||
if (flag & 2)
|
|
||||||
change_mask &= (known_user_mask | known_su_mask);
|
|
||||||
if (change_mask == 0) {
|
if (change_mask == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (change_mask == ~((uint64_t) 0)) {
|
} else if (change_mask == ~((uint64_t) 0)) {
|
||||||
|
@ -8187,6 +8187,27 @@ int iso_util_decode_lfa_flags(char *flags_text, uint64_t *lfa_flags, int flag);
|
|||||||
*/
|
*/
|
||||||
void iso_util_get_lfa_masks(uint64_t *user_settable, uint64_t *su_settable,
|
void iso_util_get_lfa_masks(uint64_t *user_settable, uint64_t *su_settable,
|
||||||
uint64_t *non_settable, uint64_t *unknown);
|
uint64_t *non_settable, uint64_t *unknown);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the effective change mask which will be used by
|
||||||
|
* iso_local_set_lfa_flags() with the same input of parameters change_mask
|
||||||
|
* and flag bits 0 and 1.
|
||||||
|
*
|
||||||
|
* @param change_mask
|
||||||
|
* Tells which bits of lfa_flags are meant to change attribute flags
|
||||||
|
* of the file. Submit ~((uint64_t) 0) if all bits may cause changes.
|
||||||
|
* The set of changeable bits may further be restricted by bit0 and bit1
|
||||||
|
* of parameter flag.
|
||||||
|
* @param flag
|
||||||
|
* Bitfield for control purposes
|
||||||
|
* bit0= do not try to change known superuser flags
|
||||||
|
* bit1= change only known chattr settable flags
|
||||||
|
*
|
||||||
|
* @since 1.5.8
|
||||||
|
*/
|
||||||
|
uint64_t iso_util_get_effective_lfa_mask(uint64_t change_mask, int flag);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Default in case that the compile environment has no macro PATH_MAX.
|
/* Default in case that the compile environment has no macro PATH_MAX.
|
||||||
|
@ -392,6 +392,7 @@ iso_node_get_lfa_flags;
|
|||||||
iso_node_set_lfa_flags;
|
iso_node_set_lfa_flags;
|
||||||
iso_util_decode_lfa_flags;
|
iso_util_decode_lfa_flags;
|
||||||
iso_util_encode_lfa_flags;
|
iso_util_encode_lfa_flags;
|
||||||
|
iso_util_get_effective_lfa_mask;
|
||||||
iso_util_get_lfa_masks;
|
iso_util_get_lfa_masks;
|
||||||
} LIBISOFS6;
|
} LIBISOFS6;
|
||||||
|
|
||||||
|
@ -2642,3 +2642,23 @@ void iso_util_get_lfa_masks(uint64_t *user_settable, uint64_t *su_settable,
|
|||||||
*unknown = 0xffffffff8d602200;
|
*unknown = 0xffffffff8d602200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param flag Bitfield for control purposes
|
||||||
|
* bit0= do not try to change known superuser flags
|
||||||
|
* bit1= change only known chattr settable flags
|
||||||
|
*/
|
||||||
|
uint64_t iso_util_get_effective_lfa_mask(uint64_t change_mask, int flag)
|
||||||
|
{
|
||||||
|
uint64_t known_user_mask, known_su_mask, non_settable, unknown;
|
||||||
|
|
||||||
|
iso_util_get_lfa_masks(&known_user_mask, &known_su_mask, &non_settable,
|
||||||
|
&unknown);
|
||||||
|
if (flag & 1)
|
||||||
|
change_mask &= ~known_su_mask;
|
||||||
|
if (flag & 2)
|
||||||
|
change_mask &= (known_user_mask | known_su_mask);
|
||||||
|
return change_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user