fazbear201 / winezeug

Automatically exported from code.google.com/p/winezeug
1 stars 0 forks source link

symlinked $HOME fails owner check #88

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
dfaure wrote in with the following bug and fix:

If $HOME is a symlink, it aborts, saying:
You (dfaure) don't own /home/dfaure. Don't run winetricks as another user!

The fix is below:   (simply adding the -H option to ls)

--- winetricks.1        2009-12-14 05:25:58.000000000 +0100
+++ winetricks  2010-01-03 22:52:21.000000000 +0100
@@ -117,7 +117,7 @@ die_if_user_not_dirowner() {
        checkdir=`dirname "$1"`
    fi
    nuser=`id -u`
-    nowner=`ls -l -n -d "$checkdir" | awk '{print $3}'`
+    nowner=`ls -l -n -H -d "$checkdir" | awk '{print $3}'`
    if test x$nuser != x$nowner
    then
        die "You (`id -un`) don't own $checkdir. Don't run winetricks as 
another user!"

I guess another solution would be to use "stat", I don't know which one is 
more portable though.

Original issue reported on code.google.com by daniel.r...@gmail.com on 4 Jan 2010 at 11:58

GoogleCodeExporter commented 8 years ago
This is an old Sun manpage:
http://bama.ua.edu/cgi-bin/man-cgi?ls+1

but doesn't seem to support it there. Not sure on more current 
Solaris/OpenSolaris.

FreeBSD supports it:
http://www.freebsd.org/cgi/man.cgi?query=ls

OpenBSD doesn't support it:
http://www.openbsd.org/cgi-bin/man.cgi?
query=ls&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

NetBSD doesn't support it:
http://netbsd.gw.com/cgi-bin/man-cgi?ls++NetBSD-current

but they all support -L, which may work? 
"For each file, if it's a link, evaluate file information and file type of the 
referenced file and not the link itself; however still print the link name, 
unless 
used with -l, for example."
I didn't test it though.

Original comment by austinenglish@gmail.com on 7 Jan 2010 at 9:51

GoogleCodeExporter commented 8 years ago
BTW, I asked Triskelios (Albert Lee) on IRC, apparently OpenSolaris supports it 
now, 
though he's not sure when it was added.

Original comment by austinenglish@gmail.com on 7 Jan 2010 at 10:07

GoogleCodeExporter commented 8 years ago
-L looks like the right way to go.

I was going to suggest find $checkdir -L -user `id -un` -prune to save a few
processes, but find's return value is not meaningful.

Original comment by triskelios on 7 Jan 2010 at 11:36

GoogleCodeExporter commented 8 years ago
Should be fixed by http://code.google.com/p/winezeug/source/detail?r=906

Original comment by austinenglish@gmail.com on 8 Jan 2010 at 8:55