Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Possible permissions problems with scripts from cron/xinit
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
fraun
n00b
n00b


Joined: 15 Apr 2020
Posts: 7

PostPosted: Wed May 20, 2020 9:50 am    Post subject: Possible permissions problems with scripts from cron/xinit Reply with quote

Hi,

I'm not really sure what the problem is and don't know what logs or details to paste...

Example 1: offlineimap

I use a postsynchook to run a bash script in ~/bin. This script runs when I call offlineimap through a terminal, but doesn't run when it's called through cron. Everything else works fine regarding offlineimap through cron and cron is being run for my user. When I create a file using cron, ie touch file, it has the correct permissions.

Example 2: sxhkd

I use sxhkd for window management. When it is started through startup scripts like xprofile or xinitrc I cannot give it bash scripts to run stored in ~/bin. But like with offlineimap, if I start sxhkd through a terminal logged in as a user then it runs any script no problem.

Thanks for any help
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Wed May 20, 2020 10:52 am    Post subject: Reply with quote

If you run scripts or programs from cron or during system bootup, the environment will be different, especially the PATH variable.

Add the line below to your scripts
Code:
export >"/tmp/env-$(/bin/date +%s).txt"

and run them from your shell, from cron and during system bootup. Can you see the difference?
Back to top
View user's profile Send private message
fraun
n00b
n00b


Joined: 15 Apr 2020
Posts: 7

PostPosted: Wed May 20, 2020 11:29 am    Post subject: Reply with quote

Ok, I think I'm close to the problem. What you've said makes sense and through some more digging i think some of my problems are that DBUS_SESSION_BUS_ADDRESS isn't being set.

when I look at /tmp/env-$(/bin/date +%s).txt its super short:

Code:


HOME=/home/fraun
LANG=en_GB.utf8
LOGNAME=fraun
OLDPWD=/home/fraun
PATH=/usr/bin:/bin
PWD=/home/fraun
SHELL=/bin/sh
SHLVL=2
USER=fraun
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=background
XDG_SESSION_ID=40
XDG_SESSION_TYPE=unspecified



While
Code:
 env
gives me a much longer output as I'd expect. Not sure if this is how it should be or not...


Edit: Exporting the correct DBUS_SESSION_BUS_ADDRESS in one of my scripts has solved the offlineimap problem. But I'm still not sure if I should be doing something different with exporting my environment.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum