security/doas can't work with zsh alias

alphachi alphachi at mediaspirit.org
Tue Jul 18 16:16:10 UTC 2017


This works:
% echo "alias doas='doas '" >> ~/.zshrc

Thanks for the thread:
https://forums.freebsd.org/threads/61539/

2017-06-27 16:48 GMT+08:00 alphachi <alphachi at mediaspirit.org>:

> So I think the simplest approach is: run "doas -s" and stay this shell for
> dealing alias requirements.
>
> Any other ideas?
>
> 2017年6月27日 14:13,"Polytropon" <freebsd at edvax.de>写道:
>
>> On Mon, 26 Jun 2017 20:25:02 +0800, alphachi wrote:
>> > I'm preparing to migrate to doas and the following commands are my test:
>> >
>> > % cat /usr/local/etc/doas.conf
>> > permit nopass keepenv fbsd as root
>> > permit nopass keepenv root as root
>> > % id -nu
>> > fbsd
>> > % doas id -nu
>> > root
>> > % echo $SHELL
>> > /usr/local/bin/zsh
>> > % doas echo $SHELL
>> > /usr/local/bin/zsh
>> > % alias
>> > vi=vim
>> > % doas alias
>> > %
>> >
>> > As this shows, doas doesn't know this alias, so "doas vi" can't invoke
>> > installed vim.
>> >
>> > Is this reasonable or just my mistake? How to enable zsh alias for doas?
>>
>> A possible explanation is that the subshell that executes the
>> "alias" (internal) command provided through doas does not inherit
>> the environment that stored the alias for the user shell; in
>> such a case, root's environment (without the alias) will be
>> used while the doas shell is running, that's why the "vi=vim"
>> setting is not in that environment.
>>
>> However, that exactly seems to conflict with the "keepenv"
>> option provided by doas.conf, except of course aliases are
>> being handled independently from environmental variables
>> (which the "env" in "keepenv" could refer to).
>>
>>
>>
>> --
>> Polytropon
>> Magdeburg, Germany
>> Happy FreeBSD user since 4.0
>> Andra moi ennepe, Mousa, ...
>>
>


-- 
Paranoid in Sabbath ...


More information about the freebsd-questions mailing list