File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed
Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change 8585 ansible.builtin.copy :
8686 content : |
8787 #!/bin/bash
88- _raw_args="$@"
89- _sanitized_args=$(echo $_raw_args | sed -e 's/--cmd=[^ ]*//g; s/--repo-host-cmd=[^ ]*//g; s/--config=[^ ]*//g' )
90- exec sudo -u pgbackrest /var/lib/pgbackrest/.nix-profile/bin/pgbackrest "$_sanitized_args"
88+ # Sanitize dangerous arguments
89+ sanitized_args=()
90+ while [[ $# -gt 0 ]]; do
91+ case "$1" in
92+ --cmd=*|--cmd)
93+ # Skip --cmd and its value
94+ [[ "$1" == "--cmd" ]] && shift
95+ shift || true
96+ ;;
97+ --ssh-cmd=*|--ssh-cmd)
98+ # Skip --ssh-cmd and its value
99+ [[ "$1" == "--ssh-cmd" ]] && shift
100+ shift || true
101+ ;;
102+ --repo-host-cmd=*|--repo-host-cmd)
103+ # Skip --repo-host-cmd and its value
104+ [[ "$1" == "--repo-host-cmd" ]] && shift
105+ shift || true
106+ ;;
107+ --config=*|--config)
108+ # Skip --config and its value
109+ [[ "$1" == "--config" ]] && shift
110+ shift || true
111+ ;;
112+ *)
113+ sanitized_args+=("$1")
114+ shift
115+ ;;
116+ esac
117+ done
118+ exec sudo -u pgbackrest /var/lib/pgbackrest/.nix-profile/bin/pgbackrest "${sanitized_args[@]}"
91119 dest : ' /usr/bin/pgbackrest'
92120 group : ' root'
93121 mode : ' 0755'
You can’t perform that action at this time.
0 commit comments