Weird behaviour when installed as root, run as normal user

35 views
Skip to first unread message

jimi...@gmail.com

unread,
Jul 27, 2013, 4:46:44 AM7/27/13
to babush...@googlegroups.com
So I'm trying to run a task as a local user but I'm getting a weird error about not being able to find the dep


If I run the dep as sudo it finds it easily... but I actually want to run as the local user.

Babs is installed in /usr/local/babushka and is upto date.
The local user has it's own sources directory pulled down 


And that task does exist


No idea what is going on... but I'm doing some digging.... 

Looks like this line in lib/babushka/source.rb is the problem


p source_prefix # => #<Fancypath:/home/dev/.babushka/sources>
p source_prefix.glob('*') # => []

Looks like something weird is happening when it tries to do the glob... debug statements reveal it's looking in the right place

#<Fancypath:/home/dev/.babushka/sources> /home/dev/.babushka/sources/*

But glob returns nothing while

20130727 18:44:19 dev@ip-10-248-82-190:/usr/local/babushka (master) irb
>> Dir.glob('/home/dev/.babushka/sources/*')
=> ["/home/dev/.babushka/sources/benhoskings"]

Any one come across this before?

Ben Hoskings

unread,
Jul 27, 2013, 4:54:14 AM7/27/13
to babush...@googlegroups.com
That's a strange one. Fancypath#glob is just a wrapper; all it's doing
in this case is

Dir.glob((self / '*').to_s)

Which should have the same effect.

Could you try this at the console?

Dir.glob(('/home/dev/.babushka/sources' / '*').to_s)

- Ben
> --
> --
> To post, email babush...@googlegroups.com
> To unsubscribe, email babushka_app...@googlegroups.com
> ~
> http://babushka.me
> http://github.com/benhoskings/babushka
> http://groups.google.com/group/babushka_app
>
> ---
> You received this message because you are subscribed to the Google Groups
> "babushka_app" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to babushka_app...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

jimi...@gmail.com

unread,
Jul 27, 2013, 8:47:32 AM7/27/13
to babush...@googlegroups.com
Yeah I know - tres weird

20130727 22:43:34 dev@ip-10-248-82-190:/usr/local/babushka (master) which ruby
/home/dev/.rvm/rubies/ruby-1.9.3-p374/bin/ruby
20130727 22:43:37 dev@ip-10-248-82-190:/usr/local/babushka (master) /usr/bin/ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/home/dev/.babushka/sources' / '*').to_s)"
["/home/dev/.babushka/sources/benhoskings"]
20130727 22:44:10 dev@ip-10-248-82-190:/usr/local/babushka (master) ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/home/dev/.babushka/sources' / '*').to_s)"
["/home/dev/.babushka/sources/benhoskings"]

I'm thinking it must have something to do with ruby versions... but every version of ruby on my system is returning the correct result

20130727 22:45:17 dev@ip-10-248-82-190:/usr/local/babushka (master) /usr/bin/env ruby
p RUBY_VERSION
"1.9.3"
20130727 22:46:00 dev@ip-10-248-82-190:/usr/local/babushka (master) /usr/bin/env ruby
class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/home/dev/.babushka/sources' / '*').to_s)
["/home/dev/.babushka/sources/benhoskings"]

jimi...@gmail.com

unread,
Jul 27, 2013, 8:57:38 AM7/27/13
to babush...@googlegroups.com, jimi...@gmail.com
It seems to come down to the flags used... 

The wrapper around glob passes down a flag too, which in this case is 8 

20130727 22:53:32 dev@ip-10-248-82-190:/usr/local/babushka (master) ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/home/dev/.babushka/sources' / '*').to_s, File::FNM_CASEFOLD)"
[]

So ... it's the default flag that is used there is for some reason killing any result from Dir.glob

jimi...@gmail.com

unread,
Jul 27, 2013, 9:13:21 AM7/27/13
to babush...@googlegroups.com, jimi...@gmail.com
Interestingly, further experiments - /lib/* works, /opt/* doesn't, /etc/* does, /home/* doesn't

20130727 23:11:41 dev@ip-10-248-82-190:/usr/local/babushka (master) ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/lib/*').to_s, File::FNM_CASEFOLD)"
["/lib/klibc-LZ1cv1NoEVO2ugnvqTw3e4qPc8Y.so", "/lib/udev", "/lib/libproc-3.2.8.so", "/lib/libip4tc.so.0", "/lib/libxtables.so.7.0.0", "/lib/terminfo", "/lib/cpp", "/lib/libnl-3.so.200", "/lib/libnewt.so.0.52", "/lib/ld-linux.so.2", "/lib/libulockmgr.so.1.0.1", "/lib/libdevmapper.so.1.02.1", "/lib/ufw", "/lib/libply-boot-client.so.2.0.0", "/lib/apparmor", "/lib/libnl-3.so.200.3.0", "/lib/libply.so.2.0.0", "/lib/xtables", "/lib/resolvconf", "/lib/firmware", "/lib/init", "/lib/libply-boot-client.so.2", "/lib/hdparm", "/lib/libply.so.2", "/lib/plymouth", "/lib/libnl-genl-3.so.200.3.0", "/lib/libply-splash-graphics.so.2", "/lib/modules", "/lib/libiptc.so.0.0.0", "/lib/libply-splash-core.so.2", "/lib/lsb", "/lib/libip6tc.so.0.0.0", "/lib/libipq_pic.so.0.0.0", "/lib/libnl-genl-3.so.200", "/lib/libiptc.so.0", "/lib/libipq_pic.so.0", "/lib/libipq.so.0", "/lib/crda", "/lib/libply-splash-graphics.so.2.0.0", "/lib/libulockmgr.so.1", "/lib/libiw.so.30", "/lib/systemd", "/lib/i386-linux-gnu", "/lib/libply-splash-core.so.2.0.0", "/lib/libfuse.so.2.8.6", "/lib/libxtables.so.7", "/lib/libnewt.so.0.52.11", "/lib/libip4tc.so.0.0.0", "/lib/recovery-mode", "/lib/libfuse.so.2", "/lib/libipq.so.0.0.0", "/lib/libip6tc.so.0"]
20130727 23:11:48 dev@ip-10-248-82-190:/usr/local/babushka (master) ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/etc/*').to_s, File::FNM_CASEFOLD)"
["/etc/fstab", "/etc/nologin", "/etc/vtrgb", "/etc/iproute2", "/etc/ucf.conf", "/etc/cloud", "/etc/ifplugd", "/etc/gshadow-", "/etc/udev", "/etc/ca-certificates.conf", "/etc/nsswitch.conf", "/etc/mysql", "/etc/passwd", "/etc/profile.d", "/etc/mailcap.order", "/etc/bash_completion", "/etc/mailname", "/etc/sysctl.conf", "/etc/groff", "/etc/nanorc", "/etc/os-release", "/etc/update-manager", "/etc/mke2fs.conf", "/etc/ltrace.conf", "/etc/sgml", "/etc/terminfo", "/etc/issue.net", "/etc/rc6.d", "/etc/apt", "/etc/apport", "/etc/kbd", "/etc/at.deny", "/etc/rcS.d", "/etc/insserv.conf", "/etc/cron.hourly", "/etc/shadow", "/etc/network", "/etc/rmt", "/etc/emacs", "/etc/fstab.d", "/etc/kernel", "/etc/depmod.d", "/etc/rc1.d", "/etc/issue", "/etc/rc3.d", "/etc/pam.d", "/etc/updatedb.conf", "/etc/protocols", "/etc/lsb-release", "/etc/ufw", "/etc/resolv.conf", "/etc/postfix", "/etc/wgetrc", "/etc/login.defs", "/etc/fonts", "/etc/grub.d", "/etc/cron.monthly", "/etc/timezone", "/etc/default", "/etc/ld.so.cache", "/etc/profile", "/etc/rc.local", "/etc/cron.weekly", "/etc/byobu", "/etc/vim", "/etc/logrotate.conf", "/etc/passwd-", "/etc/alternatives", "/etc/group-", "/etc/rsyslog.d", "/etc/insserv", "/etc/pam.conf", "/etc/xml", "/etc/inputrc", "/etc/apparmor", "/etc/mime.types", "/etc/initramfs-tools", "/etc/magic.mime", "/etc/rc5.d", "/etc/calendar", "/etc/postgresql-common", "/etc/fuse.conf", "/etc/screenrc", "/etc/resolvconf", "/etc/ppp", "/etc/init", "/etc/wpa_supplicant", "/etc/debian_version", "/etc/motd", "/etc/bash.bashrc", "/etc/debconf.conf", "/etc/opt", "/etc/deluser.conf", "/etc/sysctl.d", "/etc/manpath.config", "/etc/libnl-3", "/etc/gshadow", "/etc/legal", "/etc/zsh_command_not_found", "/etc/init.d", "/etc/python", "/etc/locale.alias", "/etc/ssl", "/etc/python2.7", "/etc/services", "/etc/lsb-base", "/etc/ntp.conf", "/etc/hosts.deny", "/etc/cron.d", "/etc/dbus-1", "/etc/cron.daily", "/etc/ca-certificates", "/etc/ld.so.conf", "/etc/shells", "/etc/perl", "/etc/w3m", "/etc/skel", "/etc/console-setup", "/etc/mailcap", "/etc/magic", "/etc/apparmor.d", "/etc/gai.conf", "/etc/modules", "/etc/postgresql", "/etc/lsb-base-logging.sh", "/etc/pm", "/etc/localtime", "/etc/adjtime", "/etc/apache2", "/etc/modprobe.d", "/etc/hostname", "/etc/ec2_version", "/etc/kernel-img.conf", "/etc/rc4.d", "/etc/bash_completion.d", "/etc/acpi", "/etc/update-motd.d", "/etc/blkid.tab", "/etc/blkid.conf", "/etc/mtab", "/etc/host.conf", "/etc/group", "/etc/rpc", "/etc/systemd", "/etc/shadow-", "/etc/ld.so.conf.d", "/etc/popularity-contest.conf", "/etc/sudoers", "/etc/rsyslog.conf", "/etc/ldap", "/etc/apm", "/etc/update-notifier", "/etc/hdparm.conf", "/etc/dpkg", "/etc/crontab", "/etc/dhcp", "/etc/hosts.allow", "/etc/landscape", "/etc/logcheck", "/etc/bindresvport.blacklist", "/etc/security", "/etc/ssh", "/etc/hosts", "/etc/adduser.conf", "/etc/insserv.conf.d", "/etc/environment", "/etc/rc0.d", "/etc/networks", "/etc/securetty", "/etc/X11", "/etc/rc2.d", "/etc/sudoers.d", "/etc/newt", "/etc/logrotate.d", "/etc/aliases", "/etc/chatscripts"]

20130727 23:11:57 dev@ip-10-248-82-190:/usr/local/babushka (master) ruby -e "class String; def /(other); File.join(self, other); end; end; p Dir.glob(('/opt/*').to_s, File::FNM_CASEFOLD)"
[]

jimi...@gmail.com

unread,
Jul 27, 2013, 9:14:47 AM7/27/13
to babush...@googlegroups.com, jimi...@gmail.com
Scratch that... opt does work... it was just empty... but home def doesn't work

Ben Hoskings

unread,
Jul 27, 2013, 9:18:04 AM7/27/13
to babush...@googlegroups.com, Jamie Cook
Interesting, looks like case folding prevents matching on some ruby
version. Could you paste the output of these on the box where it's
failing?

which ruby
ruby --version
babushka --version
babushka c -> 'Babushka.host.description'

- Ben

jimi...@gmail.com

unread,
Jul 27, 2013, 9:18:38 AM7/27/13
to babush...@googlegroups.com, jimi...@gmail.com
I think it was because /home was not readable by anyone other than root

so it was doing something recursively and falling over at the first hurdle... even though the final directory /home/dev was readable

changing the read permissions of /home to be more open fixed this...

Ben Hoskings

unread,
Jul 27, 2013, 10:14:29 AM7/27/13
to babush...@googlegroups.com, Jamie Cook
Aha :)

Glad you found the cause. It's a shame that Dir.glob doesn't raise an
exception in that case.

jimi...@gmail.com

unread,
Jul 27, 2013, 9:12:14 PM7/27/13
to babush...@googlegroups.com, Jamie Cook
I'm not sure it should be an exception... you shouldn't need permission to /home/ to read /home/dev (if it's specified as an absolute path)
And the behaviour of Dir.glob(pattern) is as expected, it's just the behaviour of Dir.glob(pattern, FNM_CASEFOLD) that is unexpected.

b...@hoskings.net

unread,
Jul 27, 2013, 11:33:02 PM7/27/13
to babush...@googlegroups.com
Yeah. I just meant that if it's going to fail it should fail loudly; you're right that those permissions shouldn't be a problem.

Sent from Mailbox for iPhone
Reply all
Reply to author
Forward
0 new messages