----- "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.

Cheers,
Caspar

> 
>       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

-- 
Kernel Associate Quality Engineer
Red Hat Inc. (Beijing R&D Branch)

Red Hat China R&D Branch Unit 907, North Tower C, 
  Raycom Infotech Park, No.2 Kexueyuan Nanlu, 
  Haidian District, Beijing 100190

TEL: +86-10-62608150
Web: http://www.redhat.com/
Hi,
	Most automated testing systems have no tty when running tests,
	so the utimensat01 test may fail with the following error msg:

	sudo: sorry, you must have a tty to run sudo

	to avoid this, commenting `Defaults    requiretty' line in
	/etc/sudoers can make this testcase work. After test finished,
	restore this line.

	Signed-off-by: Caspar ZHANG <[email protected]>
---
diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh	2010-04-01 14:23:11.000000000 +0800
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh	2010-04-28 10:56:24.006421192 +0800
@@ -43,6 +43,21 @@
      exit 1;
 fi
 
+# Since some automated testing systems have no tty while testing,
+# delete this line in /etc/sudoers to avoid the error message:
+# `sudo: sorry, you must have a tty to run sudo'
+if grep -q "^Defaults.*requiretty" /etc/sudoers; then
+	echo "${TEST_PROG} 0 INFO : Comment requiretty in /etc/sudoers for automated testing systems"
+	sed -i "s/^Defaults.*requiretty/# Defaults    requiretty/" /etc/sudoers
+	trap 'trap EXIT; teardown' EXIT
+fi
+
+teardown()
+{
+	echo "${TEST_PROG} 0 INFO : Restore requiretty in /etc/sudoers"
+	sed -i "s/^# Defaults    requiretty/Defaults    requiretty/" /etc/sudoers
+}
+
 # Summary counters of all test results
 
 test_num=0
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to