Skip to content

Commit

Permalink
Restricted log file permissions to 0600.
Browse files Browse the repository at this point in the history
Added 'starting' log message to UDP proxy.
  • Loading branch information
yurivict committed May 17, 2015
1 parent 9ff6cbb commit 8dade7e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions tiny-dhcp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def log_discard(what):
sys.exit("Only root can run tiny-dhcp-server")

## starting
tu.mk_file_rw(logfile())
log('starting')

## signals
Expand Down
1 change: 1 addition & 0 deletions tiny-udp-anti-nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def update_rev(pkt):
sys.exit("Only root can run tiny-udp-anti-nat")

## starting
tu.mk_file_rw(logfile())
log('starting (divert-ip=%s, divert-port=%s)' % (arg_clnt_divert_ip, arg_clnt_divert_port))

## signals
Expand Down
11 changes: 11 additions & 0 deletions tiny-udp-proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,17 @@ def create_sock_raw_ip():
## MAIN cycle
##

## permissions
if not os.geteuid()==0:
sys.exit("Only root can run tiny-udp-proxy")

## starting
tu.mk_file_rw(logfile())
log('starting')

## signals
tu.handle_signals(lambda msg: log(msg))

# run cmd-up if any
if arg_cmd_up != None:
res = os.system(arg_cmd_up)
Expand Down
4 changes: 4 additions & 0 deletions tiny_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
def tm_log():
return datetime.datetime.now().strftime('[%Y-%m-%d %H:%M:%S %Z]')

def mk_file_rw(fname):
fh = os.open ("qq1.junk", os.O_CREAT, 0600)
os.close(fh)

def drop_privileges3(uid_name, gid_name, files):
# get the uid/gid from the name
new_uid = pwd.getpwnam(uid_name).pw_uid
Expand Down

0 comments on commit 8dade7e

Please sign in to comment.