Skip to content

quotes... #1

@ajneu

Description

@ajneu

Hi,

please compare:

sudo ./nosudo -u'#1000' /bin/bash -c "echo -e 'a\nb\nc\n'; echo -e 'a\nb\nc\n'; id -u; id -u;"

with

sudo          -u'#1000' /bin/bash -c "echo -e 'a\nb\nc\n'; echo -e 'a\nb\nc\n'; id -u; id -u;"

Maby requoting can help?

#!/usr/bin/env bash                                                                                                                                                                      

# https://blogs.gentoo.org/agriffis/2006/06/26/requoting_in_bash/                                                                                                                        
function requote {
    declare arg
    for arg; do
        arg=$(printf '%q' "$arg")
        printf '%s ' "${arg:-''}"
    done
}

ARGS=$(requote "${@}")
eval "$ARGS"

Usage:
./myscript.sh sudo -u'#1000' /bin/bash -c "echo -e 'a\nb\nc\n'; echo -e 'a\nb\nc\n'; id -u; id -u;"

For now, I've decided to use real sudo instead...

(Also: real sudo can run a command under any uid, while su needs a user with that uid to actually exist. That seems to be a limitation of su, though...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions