diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-13 18:50:33 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-13 18:53:16 (EDT) |
commit | 575858a3709d03b6348add5721cd02e320b424bf (patch) | |
tree | 3dfe629809b67e2ace96fe959d04bf9795f4a8c5 /src | |
parent | bfc5e48be90383aea647a061b8d97518c4274551 (diff) |
Protect against cmd operands beginning with "-"
Diffstat (limited to 'src')
-rw-r--r-- | src/ob-buildopk.sh | 4 | ||||
-rw-r--r-- | src/ob-gencontrol.sh | 8 | ||||
-rw-r--r-- | src/ob-installdocs.sh | 14 | ||||
-rw-r--r-- | src/ob-installplatconf.sh | 6 | ||||
-rw-r--r-- | src/ob-unpacksource.sh | 2 | ||||
-rw-r--r-- | src/opkbuild.sh | 9 |
6 files changed, 22 insertions, 21 deletions
diff --git a/src/ob-buildopk.sh b/src/ob-buildopk.sh index cfe7585..185cc20 100644 --- a/src/ob-buildopk.sh +++ b/src/ob-buildopk.sh @@ -28,8 +28,8 @@ build_opk() arch="${3}" plat="${4}" - (cd "${binary}.data" && tar -czf '../data.tar.gz' '.') - (cd "${binary}.control" && tar -czf '../control.tar.gz' '.') + (cd -- "${binary}.data" && tar -czf '../data.tar.gz' '.') + (cd -- "${binary}.control" && tar -czf '../control.tar.gz' '.') tar -czf "../../${binary}_${version}_${arch}_${plat}.opk" \ 'debian-binary' 'data.tar.gz' 'control.tar.gz' diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index 434e491..94c2471 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -58,7 +58,7 @@ gen_control() # patch opkg and submit a bug report. inst_size=$((($inst_size + 1023) / 1024)) - mkdir -p "${binary}.control" + mkdir -p -- "${binary}.control" cat >"${binary}.control/control" <<-EOF Package: ${binary} @@ -121,7 +121,7 @@ install_maintainer_scripts() if [ -L "../${binary}.pkg/${script}" ]; then target="$(ls -l "../${binary}.pkg/${script}")" target="${target#* -> }" - ln -s "${target}" "${binary}.control/${script}" + ln -s -- "${target}" "${binary}.control/${script}" elif [ -r "../${binary}.pkg/${script}" ]; then cp "../${binary}.pkg/${script}" "${binary}.control/${script}" chmod 755 "${binary}.control/${script}" @@ -139,7 +139,7 @@ gen_conffiles() find "${binary}.data/etc" -type f | sed "s@^${binary}.data@@" \ >"${binary}.control/conffiles" if [ -z "$(head -n 1 "${binary}.control/conffiles")" ]; then - rm -f "${binary}.control/conffiles" + rm -f -- "${binary}.control/conffiles" else chmod 644 "${binary}.control/conffiles" fi @@ -156,7 +156,7 @@ gen_md5sums() sed "s@ ${binary}.data@ @" \ >"${binary}.control/md5sums" if [ -z "$(head -n 1 "${binary}.control/md5sums")" ]; then - rm -f "${binary}.control/md5sums" + rm -f -- "${binary}.control/md5sums" else chmod 644 "${binary}.control/md5sums" fi diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index e594610..0b3a342 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -29,22 +29,22 @@ install_docs() for src in ${srcs}; do if [ -f "${src}" ]; then - if ! mkdir -p "$(dirname "${data_doc_dir}/${dest}")" + if ! mkdir -p -- "$(dirname -- "${data_doc_dir}/${dest}")" then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi - if ! cp -R "${src}" "${data_doc_dir}/${dest}"; then + if ! cp -R -- "${src}" "${data_doc_dir}/${dest}"; then ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" return 1 fi elif [ -d "${src}" ]; then - if ! mkdir -p "$(dirname "${data_doc_dir}/${dest}")" + if ! mkdir -p -- "$(dirname -- "${data_doc_dir}/${dest}")" then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi - if ! cp -R "${src}/." "${data_doc_dir}/${dest}"; then + if ! cp -R -- "${src}/." "${data_doc_dir}/${dest}"; then ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" return 1 fi @@ -80,7 +80,7 @@ main() ob_info "$(ob_get_msg 'docs_already_installed')" "${pkg}" else ob_info "$(ob_get_msg 'installing_docs')" "${pkg}" - if ! mkdir -p "${data_doc_dir}"; then + if ! mkdir -p -- "${data_doc_dir}"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi @@ -97,11 +97,11 @@ main() ob_info "$(ob_get_msg 'docs_already_linked')" "${pkg}" else ob_info "$(ob_get_msg 'linking_docs')" "${pkg}" - if ! mkdir -p "${data_doc_dir%/*}"; then + if ! mkdir -p -- "${data_doc_dir%/*}"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 fi - if ! ln -s "${doc_pkg_doc_dir}" \ + if ! ln -s -- "${doc_pkg_doc_dir}" \ "${data_doc_dir}"; then ob_error "$(ob_get_msg 'cant_ln_doc_dir')" return 1 diff --git a/src/ob-installplatconf.sh b/src/ob-installplatconf.sh index d980ff8..1ee90cd 100644 --- a/src/ob-installplatconf.sh +++ b/src/ob-installplatconf.sh @@ -37,8 +37,8 @@ copy_config() fi # Make sure the destination directory exists. - dir="(dirname "${dest_base}/${dest}")" - if ! mkdir -p "${dir}"; then + dir="$(dirname -- "${dest_base}/${dest}")" + if ! mkdir -p -- "${dir}"; then ob_error "$(ob_get_msg 'cant_make_config_dest_dir')" \ "${dir}" return 1 @@ -64,7 +64,7 @@ copy_config() # Copy the config file(s). ob_info "$(ob_get_msg 'copying_config_file')" "${src}" "${dest}" - if ! cp -p "${src_base}/${src}" "${dest_base}/${dest}"; then + if ! cp -p -- "${src_base}/${src}" "${dest_base}/${dest}"; then ob_error "$(ob_get_msg 'cant_copy_config_file')" return 1 fi diff --git a/src/ob-unpacksource.sh b/src/ob-unpacksource.sh index 98b2da1..0716257 100644 --- a/src/ob-unpacksource.sh +++ b/src/ob-unpacksource.sh @@ -114,7 +114,7 @@ extract_upstream() ob_error "$(ob_get_msg 'cant_unpack_upstream')" return 1 fi - if ! mv "${upstream_ar_dir}" 'src'; then + if ! mv -- "${upstream_ar_dir}" 'src'; then ob_error "$(ob_get_msg 'cant_move_native')" return 1 fi diff --git a/src/opkbuild.sh b/src/opkbuild.sh index 7392317..4c96098 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -245,7 +245,7 @@ build_source() src_pkg_data_base="src-${src}.data$(ob_get_system_path 'package-source' \ "${src}" "${ver}")" - if ! "${opt_uid0_cmd}" -- mkdir -p "${src_pkg_data_base}"; then + if ! "${opt_uid0_cmd}" -- mkdir -p -- "${src_pkg_data_base}"; then ob_error "$(ob_get_msg 'cant_make_src_pkg_dir')" return 1 fi @@ -255,7 +255,7 @@ build_source() ../tmp) ;; ../*) - if ! "${opt_uid0_cmd}" -- cp -Rp "${file}" \ + if ! "${opt_uid0_cmd}" -- cp -Rp -- "${file}" \ "${src_pkg_data_base}"; then ob_error "$(ob_get_msg 'cant_install_src_pkg_file')" return 1 @@ -348,12 +348,13 @@ build() return 1 ;; 'install'|'install-'*) - if ! ${opt_uid0_cmd} -- ../build "${opt_target}"; then + if ! ${opt_uid0_cmd} -- ../build -- "${opt_target}" + then return 1 fi ;; *) - if ! ../build "${opt_target}"; then + if ! ../build -- "${opt_target}"; then return 1 fi ;; |