On Apr 27, 2010, at 8:48 PM, Caspar ZHANG wrote:
>
> ----- "Garrett Cooper" <[email protected]> wrote:
>
>> On Apr 27, 2010, at 4:03 AM, Caspar ZHANG wrote:
>>
>>>
>>> ----- "Garrett Cooper" <[email protected]> wrote:
>>>
>>>> On Apr 27, 2010, at 2:23 AM, Caspar ZHANG wrote:
>>>>
>>>>> <syscalls-utimensat01-run-sudo-without-tty.patch>
>>>>
>>>> What good would this do if the value's deleted and not restored?
>> It's
>>>> better to document this IMO because then it at least brings the
>> issue
>>>> to light as there may be other areas of the tree that require this
>>>> kind of intervention.
>>>
>>> I didn't realize this matter, thanks for pointing it out. So what if
>> adding
>>> the `Defaults requiretty' value back after this test finished?
>>
>> If it's commented out (which is better than it being deleted), sure.
>> Just be sure to do the inverse operation via trap ... EXIT ;), like:
>>
>> setup
>> trap 'trap "" EXIT; teardown' EXIT
>
> Thanks Garrett, the modified patch attached.
Almost there :). Some comments:
+ trap 'trap EXIT; teardown' EXIT
Should be:
+ trap 'trap "" EXIT; teardown' EXIT
The double quotes tell the shell to ignore all future signals trapped for the
EXIT event (from bash(1)'s trap section, but the same also applies for ash(1),
which is the predecessor to dash ):
...
If arg
is absent (and there is a
single sigspec) or -, each specified signal is reset to its
original disposition (the value it had upon entrance to the
shell). If arg is the null string the signal specified by each
sigspec is ignored by the shell and by the commands it invokes.
...
The `set' sed could be like this:
pattern="[[:space:]]*Defaults[[:space:]]*requiretty.*"
sed -E -i "" -e "s/^($pattern)/#\1/" /etc/sudoers
The restore sed could be like this:
sed -E -i "" -e "s/^#($pattern)/\1/" /etc/sudoers
# with $pattern being set like before.
Don't forget the ^ anchors and the quoting's important :).
>>
>> You may want to execute the handler before the setup call is invoked
>> to ensure that everything done is properly undone in the event of a
>> failure during setup.
>> Also, watch out for cases where a user may have done:
>>
>> # requiretty
>>
>> instead of:
>>
>> requiretty
>>
>> It probably would be wise to preserve all leading and trailing
>> characters for teardown to avoid inadvertently enabling requiretty in
>> sudo.
>> The EXIT trap handler isn't 100% foolproof, but it protects against
>> all but SIGKILL or SIGSTOP from being executed as they're NMIs.
Cheers,
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list