Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved]after reboot:/bin/sh: bad interpreter: Permission d
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3648
Location: Hamburg

PostPosted: Sat Feb 18, 2017 5:37 pm    Post subject: [solved]after reboot:/bin/sh: bad interpreter: Permission d Reply with quote

I do wonder about getting this error message from cron via email at a hardened Gentoo server (only once immediately after reboot) :
Code:
/bin/sh: /home/tinderbox/tb/bin/logwatch.sh: /bin/sh: bad interpreter: Permission denied
The appropriate cron entry is:
Code:
$ crontab -l

*/1  * * * * ~/tb/bin/logwatch.sh
and the script itself is just sth like.
Code:
$ cat /home/tinderbox/tb/bin/logwatch.sh
#!/bin/sh
#
#set -x

<watch log files and ring a bell if they are non-empty>

Update:PEBKAC, it scaused by GrSec trusted path execution - I forgot to run appropriate sysctl calls early enough


Last edited by toralf on Fri Apr 07, 2017 9:35 am; edited 1 time in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sat Feb 18, 2017 6:30 pm    Post subject: Reply with quote

toralf ...

please do not provide pseudo code, if logwatch.sh calls anything that isn't available, or +x, then this can result in a 'bad interpreter' error, you can also get this if the script has windows line endings, if the script is on a filesystem with 'noexec' set, or /home is NFS. I would check/provide the following:

Code:
# ls -l /home/tinderbox/tb/bin/logwatch.sh
# cat -vET /home/tinderbox/tb/bin/logwatch.sh
# mount

It may be none of the above, so you might try changing the crontab to:

Code:
*/1  * * * * sh /home/tinderbox/tb/bin/logwatch.sh

best ... khay
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3648
Location: Hamburg

PostPosted: Sat Feb 18, 2017 7:04 pm    Post subject: Reply with quote

Well,
Code:
tinderbox@mr-fox ~ $ ls -l /home/tinderbox/tb/bin/logwatch.sh
-r-xrwx--- 1 tinderbox tinderbox 535 Feb 17 20:24 /home/tinderbox/tb/bin/logwatch.sh
tinderbox@mr-fox ~ $ cat -vET /home/tinderbox/tb/bin/logwatch.sh
#!/bin/sh$
#$
#set -x$
$
mailto="tinderbox@zwiebeltoralf.de"$
$
if [[ -s ~/nohup.out ]]; then$
  (ls -l ~/nohup.out; head -n 500 ~/nohup.out) | timeout 120 mail -s "nohup.out is non-empty" $mailto$
  truncate -s 0 ~/nohup.out$
fi$
$
f=/tmp/tinderbox.logwatch.out$
if [[ ! -f $f ]]; then$
  if [[ "$(wc -c ~/logs/* 2>/dev/null | tail -n 1)" != "0 total" ]]; then$
    ls -l ~/logs/* >> $f$
    head ~/logs/*  >> $f$
    echo -e "\nto re-activate this test again, do:  rm $f" >> $f$
    cat $f | timeout 120 mail -s "logs are non-empty" $mailto$
  fi$
fi$
$
Thx for the hint to look for commands inside of the script which might cause that error - I was somehow convinced that just the shebang line of the script itself could cause it, but ok ...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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