On 12/4/25 10:17 PM, Ionen Wolkens wrote:
> On Fri, Dec 05, 2025 at 10:21:36AM +0800, Zhixu Liu wrote:
>>> - # If we're still here, setcaps failed.
>>> + # If we're still here, setcaps failed or filecaps are
>>> disabled.
>>> + if [[ -n ${owner} || -n ${group} ]]; then
>>> + debug-print "${FUNCNAME}: setting owner on
>>> '${file}'"
>>> + chown "${owner}:${group}" "${file}" || die
>>> + fi
>>
>> if owner is a number but no group, chown will fail w/ "chown: invalid
>
> Huh, never realized this, kind of assumed it worked given `root:` does.
It makes some sense given `root:` does a name lookup, consults the db
and infers the value for {group} to be the {user}'s login group.
If using uids, there may not be an associated user; easiest to disable
support for the whole feature. It's anyways unlikely to be useful given
people working directly with uids are operating on a lower "plumbing" level.
>> spec: '2000:'", how about:
>>
>> local spec=${owner}
>> [[ -n ${group} ]] && spec+=":${group}"
>>
>> chown "${spec}" "${file}" || die
>
> Could keep it as a one-liner using ${var:+}, aka:
>
> chown "${owner}${group:+:}${group}" "${file}" || die
>
> For those that don't know :+ checks if group is empty and,
> if not, will print what's after it aka :.
>
>>
>>> if [[ -n ${mode} ]]; then
>>> - if [[ -n ${owner} || -n ${group} ]]; then
>>> - debug-print "${FUNCNAME}: setting owner on
>>> '${file}'"
>>> - chown "${owner}:${group}" "${file}" || die
>>> - fi
>>> debug-print "${FUNCNAME}: setting mode on '${file}'"
>>> chmod ${mode} "${file}" || die
>>> fi
>>> --
>>> 2.52.0
>>>
>>>
>>
>>
>> --
>> Z. Liu
>>
>
--
Eli Schwartz
OpenPGP_signature.asc
Description: OpenPGP digital signature
