This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] base-files-4.2-1: Change prompt if running with admin rights


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]