Marcio Coelho · Dec 2, 2019

Operation System Permission

Hi all...

I am try to execute a class method from JDBC connection. My method are simple, just create a file at $HOME  like this:


set sc='$zf(-1,"touch $HOME/lixo.txt > /var/tmp/log666 2>&1")

I put a log file to this commnad because it's don't work, and in log file i get this:

touch: cannot touch ‘/root/lixo.txt’: Permission denied

after to try other commands I found that user and enviromnent  variables are diferents:
I try this:

set sc='$zf(-1,"echo $USER > /var/tmp/log666 2>&1") ;Return root


set sc='$zf(-1,"echo $HOME > /var/tmp/log666 2>&1") ;return /root


set sc='$zf(-1,"whoami > /var/tmp/log666 2>&1") ; return cacheusr

I need help to write a file at $HOME using a JDBC connection in Cache 2017


w $zversion
Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.1 (Build 801U) Wed Dec 6 2017 09:23:15 EST
0 210
Discussion (8)0
Log in or sign up to continue

Well, as a cacheusr you don't have access to /root. Why not write into some temp directory?

I need to run third party software that needs a configuration file in $HOME

You can change the $HOME for cacheusr to some other dir, /home/cacheusr probably.

I try to set $HOME before to write file, but... 

when I run third party software that reads the configuration file, the $ HOME variable goes back to / root

This is works.... but sound like a workarround:

set sc='$zf(-1,"export USER=`whoami` && export HOME=$( getent passwd ""$USER"" | cut -d: -f6 ) && touch $HOME/file.txt")

I'm using the same workaround.

It works like this because $zf(-1) spawns a new process.

If you want to change the environment variable for a current process, you can use this utility.

You need to set $HOME and run the program in one call:

set sc='$zf(-1,"export HOME=/tmp && soffice")

Here's an example.