shell - Prevent a command being executed from a source'd file in Bash -



shell - Prevent a command being executed from a source'd file in Bash -

for security purposes, how can prevent command beingness executed in file source'd? example:

#!/bin/sh source file.cfg

wanted:

get="value"

unintended:

command

long story short, can't. debate how seek prevent commands beingness executed if security major concern here, source no-go. looking proper configuration facility — while source intended execute code.

for example, next code provides trivial key-value configuration file parsing:

while read -r x; declare +x -- "${x}" done < file.cfg

but both far flexibility source gives you, , far secure solution either. doesn't handle specific escaping, multi-line variables, comments… , doesn't filter assigned variables, config can override precious variables. +x argument declare ensures config file @ to the lowest degree won't modify environment exported programs.

if want go route, can seek improve this. if worried security, should think twice before using shell script @ all. writing proper shell script not trivial @ all, , total of pitfalls.

bash shell

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -