svn commit: trunk/busybox/loginutils

Tito farmatito at tiscali.it
Sun Sep 3 18:12:34 UTC 2006


On Sunday 3 September 2006 19:41, Bernhard Fischer wrote:
> On Sun, Sep 03, 2006 at 10:11:34AM -0700, vda at busybox.net wrote:
> >Author: vda
> >Date: 2006-09-03 10:11:34 -0700 (Sun, 03 Sep 2006)
> >New Revision: 16045
> >
> >Log:
> >sulogin: fix bug: -tNNN didn't work
> 
> Just a sidenote..
> 
> >@@ -87,7 +88,7 @@
> > 			close(0);
> > 			close(1);
> > 			close(2);
> >-			if (open(device, O_RDWR) >= 0) {
> >+			if (open(device, O_RDWR) == 0) {
> > 				dup(0);
> > 				dup(0);
> 
> A cursory look, init (twice), sulogin, telnetd duplicate
> dup(0);dup(0).
> 
> A couple of others have variations of dup2(0,1);dup2(0,2);
> Some manually do something like a wdup(x,y) that warns.
> 
> Perhaps something where a byte or two could be saved..

sulogin could be easily be unbloated more by doing something like:


	if (bb_getopt_ulflags (argc, argv, "t:", &timeout_arg)) {
		if (safe_strtoi(timeout_arg, &timeout)) {
			timeout = 0;
		}
	}

	argc -= optind;
	argv += optind;
	
	if (argc) {
		/* new vt becomes stdin */
		close(0);
		/* and grab new one */
		if ((fd = open(argv[0], O_RDWR)) < 0) {
			/* exits */	
			syslog(LOG_WARNING, "cannot open `%s'", argv[0]);
			bb_err_msg_and_die("cannot open `%s'", argv[0]);
		}
		/* Reassign stdout and sterr */
		dup2(fd, STDOUT_FILENO);
		dup2(fd, STDERR_FILENO);
	}

Tito
> cheers,
> Bernhard
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
> 



More information about the busybox mailing list