0

I have small script which creates a tmp files using mkstemp. My script was created using root user , but if I logged in as someother user other than root then my scripts runs but msktemp fails and says permission denied

sh: /tmp/tmpFile-khB5hH: Permission denied

Same thing while doing in RHEL 7 works and no Permission denied error, what is changed in RHEL 8. looks like RHEL 8 is checking logged on user vs effective user.

I tested this up in RHEL 7.5 and RHEL 8.4.

If someone know change in RHEL 8 which leads to permission problems please suggest. Thanks

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
cjoshi
  • 1
  • 2
    What does `ls -ld /tmp` output? See also https://unix.stackexchange.com/questions/71622/what-are-correct-permissions-for-tmp-i-unintentionally-set-it-all-public-recu – Kusalananda Aug 13 '21 at 17:12
  • + what does `touch /tmp/foo` output ? – steve Aug 13 '21 at 17:17
  • @Kusalananda drwxrwxrwt. 9 root root 195 Aug 15 06:48 /tmp – cjoshi Aug 15 '21 at 11:49
  • @steve nothing as such. – cjoshi Aug 15 '21 at 11:50
  • @steve well problem is happening because my logged on user is different from the effective use ..hence it says permission denied which it should not do. mkstemp is able to create the temp file in /tmp when logged on user and my script user is same.....thought in RHEL7 it works fine – cjoshi Aug 15 '21 at 11:53

1 Answers1

0

I have set the logged on user in my script by seteguid(getuid()) this work though it is dangerous. this make logged on user as always effective user and it doesnt fail on RHEL8.

cjoshi
  • 1