search for: stdin_fileno

Displaying 20 results from an estimated 107 matches for "stdin_fileno".

2015 Dec 02
3
[PATCH] daemon: improve internal commandrvf
.../daemon/guestfsd.c b/daemon/guestfsd.c index 0a29aa6..47245f7 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -932,21 +932,44 @@ commandrvf (char **stdoutput, char **stderror, int flags, signal (SIGPIPE, SIG_DFL); close (0); if (flag_copy_stdin) { - dup2 (flag_copy_fd, STDIN_FILENO); + if (dup2 (flag_copy_fd, STDIN_FILENO) == -1) { + perror ("dup2/flag_copy_fd"); + _exit (EXIT_FAILURE); + } } else { - /* Set stdin to /dev/null (ignore failure) */ - ignore_value (open ("/dev/null", O_RDONLY|O_CLOEXEC)); + /* Set s...
2019 Aug 27
1
[PATCH nbdkit] server: Try hard to maintain invariant that fds 0, 1 and 2 are always open.
...to + * write. + */ + open_std_file_descriptors (); + threadlocal_init (); /* The default setting for TLS depends on whether we were @@ -930,3 +938,18 @@ is_config_key (const char *key, size_t len) return true; } + +static void +open_std_file_descriptors (void) +{ + int fds[] = { STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO }; + int i, fd, fl; + + for (i = 0; i < sizeof fds / sizeof fds[0]; ++i) { + fd = fds[i]; + fl = fcntl (fd, F_GETFL, NULL); + if (fl == -1 && errno == EBADF) + /* This is best effort - don't fail. */ + open ("/dev/null", fd...
2017 Oct 09
5
Why dup()?
...tdout from ssh, weren't seeing EOF from the remote session.? It was being sent, but lost.? I tracked it down to the following code, in ssh.c, at ssh_session2_open: ??????? if (stdin_null_flag) { ??????????????? in = open(_PATH_DEVNULL, O_RDONLY); ??????? } else { ??????????????? in = dup(STDIN_FILENO); ??????? } ??????? out = dup(STDOUT_FILENO); ??????? err = dup(STDERR_FILENO); The remote session did close stdout.? The sshd from which it was spawned signaled to close stdout.? The ssh program received that signal and closed, well, something, but not stdout.? It closed a copy.? Importantl...
2020 Apr 04
0
[nbdkit PATCH 2/2] server: Sanitize stdin/out before running plugin code
...s, with or without * modification, are permitted provided that the following conditions are @@ -151,7 +151,13 @@ run_command (void) } if (pid > 0) { /* Parent process is the run command. */ - r = system (cmd); + /* Restore original stdin/out */ + if (dup2 (orig_in, STDIN_FILENO) == -1 || + dup2 (orig_out, STDOUT_FILENO) == -1) { + r = -1; + } + else + r = system (cmd); if (r == -1) { nbdkit_error ("failure to execute external command: %m"); r = EXIT_FAILURE; diff --git a/server/connections.c b/server/connections.c index...
2010 Nov 27
1
"doveadm auth user" requiring a tty
...8:36:52.000000000 +0200 +++ askpass.c 2010-11-27 19:12:03.000000000 +0100 @@ -16,8 +16,24 @@ char ch; int fd; + // A very crude attempt... this supposes that STDIN not being a tty + // may never happen outside of "doveadm auth", and that STDIN will + // always be clean. + //if (!isatty(STDIN_FILENO)) + // i_fatal("stdin isn't a TTY"); if (!isatty(STDIN_FILENO)) - i_fatal("stdin isn't a TTY"); + { + pos = 0; + while (read(STDIN_FILENO, &ch, 1) > 0) { + if (pos >= buf_size-1) + break; + if (ch == '\n' || ch == '\r') + break; +...
2011 Jan 06
1
Dovecot 2.0.7 doesn't disassociate STDERR when it daemonizes.
...al("Can't open /dev/null: %m"); fd_close_on_exec(null_fd, TRUE); } while (null_fd <= STDERR_FILENO); But stderr is missing when a later dup2() is used to release any inherited values not covered by the above: if (dup2(null_fd, STDIN_FILENO) < 0 || dup2(null_fd, STDOUT_FILENO) < 0) i_fatal("dup2(null_fd) failed: %m"); Adding a dup2 for stderr to the above statement works in my simple test case but I'm unsure if there are other issues which may require delaying it. Dovecot 1.2.16 approa...
2013 Jan 31
0
File descriptors in pipe.c
...t;value of pid is %d",pid); if (pid == -1) { rsyserr(FERROR, errno, "fork"); exit_cleanup(RERR_IPC); } if (pid == 0) { printf("\n inside the if statement"); if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 || close(to_child_pipe[1]) < 0 || // fd 4 closed close(from_child_pipe[0]) < 0 || // fd 5 closed dup2(from_child_pipe[1], STDOUT_FILENO) < 0) { rsyserr(FERROR, errno, "Failed to...
2000 Sep 09
0
2.2.0p1 PATCH: ssh/scp/slogin will invoke ssh-askpass
...r ORIG/openssh-2.2.0p1/sshconnect1.c openssh-2.2.0p1/sshconnect1.c --- ORIG/openssh-2.2.0p1/sshconnect1.c Tue Aug 22 20:46:25 2000 +++ openssh-2.2.0p1/sshconnect1.c Sat Sep 9 01:13:35 2000 @@ -191,6 +191,8 @@ char *passphrase, *comment; int type, i; int plen, clen; + int interactive = isatty(STDIN_FILENO); + char *askpass = NULL; /* Try to load identification for the authentication key. */ public = key_new(KEY_RSA); @@ -244,7 +246,15 @@ snprintf(buf, sizeof buf, "Enter passphrase for RSA key '%.100s': ", comment); if (!options.batch_mode) - passphrase = read_p...
2020 Apr 14
0
[nbdkit PATCH v2 2/3] server: Sanitize stdin/out before running plugin code
...s, with or without * modification, are permitted provided that the following conditions are @@ -151,7 +151,13 @@ run_command (void) } if (pid > 0) { /* Parent process is the run command. */ - r = system (cmd); + /* Restore original stdin/out */ + if (dup2 (orig_in, STDIN_FILENO) == -1 || + dup2 (orig_out, STDOUT_FILENO) == -1) { + r = -1; + } + else + r = system (cmd); if (r == -1) { nbdkit_error ("failure to execute external command: %m"); r = EXIT_FAILURE; diff --git a/server/connections.c b/server/connections.c index...
2006 Jan 03
2
Bug ? on ssh-agent
...h on cygwin. Though it may be a cygwin related issue, I think it's may be a bug on the main openssh tree. Thus my posting here. I'm CC'ing to the public list for information. The part of code I'm refering to is : /* XXX might close listen socket */ (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); if (fd > 2) close(fd); I'm actually launching the ssh agent from a "run.exe" script launched at the start of my X server (Cygwin/X). Things used to work perfectly until my last u...
2015 Dec 02
0
Re: [PATCH] daemon: improve internal commandrvf
...gt; index 0a29aa6..47245f7 100644 > --- a/daemon/guestfsd.c > +++ b/daemon/guestfsd.c > @@ -932,21 +932,44 @@ commandrvf (char **stdoutput, char **stderror, int flags, > signal (SIGPIPE, SIG_DFL); > close (0); > if (flag_copy_stdin) { > - dup2 (flag_copy_fd, STDIN_FILENO); > + if (dup2 (flag_copy_fd, STDIN_FILENO) == -1) { > + perror ("dup2/flag_copy_fd"); > + _exit (EXIT_FAILURE); > + } close(0) explicitly assumes that stdin is 0, which is fine, but dup2 uses STDIN_FILENO (which itself is also fine), but you should st...
2020 Apr 04
6
[nbdkit PATCH 0/2] stdin/out cleanups
This is what I've been playing with in response to my earlier question about what to do with 'nbdkit -s sh -' (https://www.redhat.com/archives/libguestfs/2020-April/msg00032.html) I'm still open to ideas on a better name, and/or whether adding <stdbool.h> to our public include files is a good idea (if not, returning int instead of bool is tolerable). Eric Blake (2):
2023 Mar 23
20
[libnbd PATCH v3 00/19] pass LISTEN_FDNAMES with systemd socket activation
V3 was here: <http://mid.mail-archive.com/20230215141158.2426855-1-lersek at redhat.com>. See the Notes section on each patch for the v4 updates. The series is nearly ready for merging: every patch has at least one R-b tag, except "socket activation: avoid manipulating the sign bit". The series builds, and passes "make check" and "make check-valgrind", at
2008 May 26
4
xvm-gate: arrow keys broken in pygrub
One of my test domUs is a opensuse 10.3 PV domain, and it has a /boot/grub/menu.lst file. pygrub is used as bootloader. With xVM 3.1.4, the arrow keys can be used in the pygrub screen. With xVM 3.3-unstable, the arrow keys don''t work for me any more. What I''ve found out so far is that: - gnome-terminal, xterm or dtterm are running with "vt100 application key
2004 Aug 25
6
sshd 3.9p1 under Reliant Unix 5.45: getpeername: Operation not supported on transport endpoint
The following is special to sshd 3.9p1 under ReliantUnix 5.45. It does not occur under ReliantUnix 5.43 nor under Solaris 5.8: `pwd`/sshd-3.9 -e -D -d -d -d Now connecting from outside [...] debug1: inetd sockets after dupping: 3, 3 debug1: get_port() calls get_sock_port(3) debug1: getpeername failed: Operation not supported on transport endpoint lsof proves FD 3 is an established TCP
2020 Apr 14
3
Re: [nbdkit PATCH v2 1/3] server: Add nbdkit_stdio_safe
...1) > return -1; > + if (!nbdkit_stdio_safe () && fd < STDERR_FILENO) { I think this could be clearer written the other way around: if (fd < STDERR_FILENO && !nbdkit_stdio_safe ()) { but then thinking about this more, why isn't it this? if (fd == STDIN_FILENO && !nbdkit_stdio_safe ()) { Anyway, these are minor points, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scrip...
2023 Mar 23
1
[libnbd PATCH v3 14/19] CONNECT_COMMAND.START: plug child process leak on error
...argv.ptr); assert (h->argv.ptr[0]); next = %.DEAD; + parentfd_transferred = false; if (nbd_internal_socketpair (AF_UNIX, SOCK_STREAM, 0, sv) == -1) { set_error (errno, "socketpair"); goto done; } /* A process is effectively in an unusable state if any of STDIN_FILENO * (fd#0), STDOUT_FILENO (fd#1) and STDERR_FILENO (fd#2) don't exist. If they * exist however, then the socket pair created above will not intersect with * the fd set { 0, 1, 2 }. This is relevant for the child-side dup2() logic * below. */ assert (sv[0] > STDERR_FILENO...
2020 Jun 01
7
server: Fix reading passwords interactively.
https://bugzilla.redhat.com/show_bug.cgi?id=1842440 Patches 1 and 2 address fairly obvious bugs in how we handle reading passwords from stdin. There are other ways we may consider fixing these bugs: - Should password=- always open /dev/tty and ignore stdin entirely? - Should we make password=-0/-1/-2 work by skipping the close? Or perhaps reopen the file descriptors on /dev/null after
2020 Jun 01
0
[PATCH nbdkit 2/3] server: Disallow -FD for stdin/stdout/stderr.
...erver/public.c index dafdfbae..2e36e43a 100644 --- a/server/public.c +++ b/server/public.c @@ -433,8 +433,8 @@ nbdkit_read_password (const char *value, char **password) if (nbdkit_parse_int ("password file descriptor", &value[1], &fd) == -1) return -1; - if (fd == STDIN_FILENO && !nbdkit_stdio_safe ()) { - nbdkit_error ("stdin is not available for reading password"); + if (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO) { + nbdkit_error ("cannot use password -FD for stdin/stdout/stderr"); return -1; }...
2010 Feb 23
1
S_ISSOCK fails in openssh >= 5.1
Starting with openssh 5.1 the following code fails (when executed on a remote host)... prior to 5.0 this worked, ie S_ISSOCK says STDIN is a socket. struct stat s; fstat(STDIN_FILENO, &s); if (S_ISSOCK(s.st_mode)) // STDIN is a socket else // STDIN is not a socket Soo... if I have a command on a remote host that includes the above code and I ssh to the remote host and execute the command, S_ISSOCK will fail if the ssh server is >= 5.1. Is this change...