[PATCH] base-files-4.2-1: Change prompt if running with admin rights
Christian Franke
Christian.Franke@t-online.de
Thu Apr 10 15:57:00 GMT 2014
Corinna Vinschen wrote:
> On Apr 9 23:50, Christian Franke wrote:
>> I used the registry check in the past because it only uses shell
>> builtins and does not rely on specific SID->gid mappings in
>> /etc/group.
> Especially given that in future there might be no /etc/group to begin
> with.
>
> But even without /etc/group, the administrator's group will have the
> gid 544. I think such a test should be sufficient?
Yes.
Result would only differ for special accounts like "Backup
Administrator" (has SeBackup/RestorePrivilege but is not member of local
admin group).
This change for my patch uses shell builtins for the string matching:
# Set PS1a if user has admin rights
unset PS1a
-if [ -r /proc/registry/HKEY_LOCAL_MACHINE/SECURITY ]; then
- PS1a="# "
-fi
+case " $(/usr/bin/id -G) " in
+ *\ 544\ *) PS1a="# " ;;
+esac
Works for me with bash, dash, mksh, posh, and zsh.
Christian
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list