Page 1 of 1

[Solved]client-connect exits on printing to file

Posted: Wed Mar 11, 2015 2:27 am
by almogbaku
Hey guys,
I have a really wired problem with the `client-connect`..
I'm trying to create very simple script called `test.sh`(with +x mode):

Code: Select all

#!/bin/bash
echo "User connected!" > test.log
I defined it on my `server.conf`:

Code: Select all

script-security 3 system
client-connect /etc/openvpn/test.sh
The problem:
This very simple script always throws error status 2 for some reason, and prevent me from connection: WARNING: Failed running command (--client-connect): external program exited with error status: 1.
When i'm trying to add `exit 0` at the end, i'm able to connect but it not creates the file.

Does someone have an idea?

Re: client-connect exits on printing to file

Posted: Wed Mar 11, 2015 6:52 am
by maikcat
naive question,

where do you want test.log to be created?
do you have permissions to write to this folder?

Michael.

Re: client-connect exits on printing to file

Posted: Wed Mar 11, 2015 10:43 am
by almogbaku
I solved it! (and it took me the whole... night.)

In case someone tackling the problem and found this post:
The problem was permissions, of course! The `test.sh` script doesn't had the right permission to write on the file.

Commenting these directives on the `server.conf` solved it:

Code: Select all

# user nobody
# group nobody
Because the `openvpn` changed the user and group after of the daemon after logging in, the script suddenly hadn't the permission to write on files at all.


Thanks!

Re: client-connect exits on printing to file

Posted: Wed Mar 11, 2015 11:03 am
by maikcat
commenting out these directives you understand that you degrade security...

a more correct approach would be to write to a location with proper permissions.

Marked as solved.

Michael.

Re: [Solved]client-connect exits on printing to file

Posted: Wed Mar 11, 2015 12:34 pm
by almogbaku
of course, thanks. I commented them only for the test mode..