search for: dup2

Displaying 20 results from an estimated 384 matches for "dup2".

Did you mean: dup
2011 Jan 06
1
Dovecot 2.0.7 doesn't disassociate STDERR when it daemonizes.
...("/dev/null", O_WRONLY); if (null_fd == -1) i_fatal("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 t...
2015 Dec 02
3
[PATCH] daemon: improve internal commandrvf
- add a flag to request chroot for the process, which is done only as very last (before chdir) operation before exec'ing the process in the child: this avoids using CHROOT_IN & CHROOT_OUT around command* invocations, and reduces the code spent in chroot mode - add failure checks for dup2 and open done in child, not proceeding to executing the process if they fail - open /dev/null without O_CLOEXEC, so it stays available for the exec'ed process, and thus we don't need to provide an own fd for stdin Followup of commit fd2f175ee79d29df101d353e2f380db27b19553a, thanks also...
2009 Aug 19
2
[PATCH libguestfs] guestfish: detect a few more failed syscalls
...perror ("pipe failed"); + return -1; + } pid = fork (); if (pid == -1) { perror ("fork"); @@ -760,7 +766,10 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd) if (pid == 0) { /* Child process. */ close (fd[1]); - dup2 (fd[0], 0); + if (dup2 (fd[0], 0) < 0) { + perror ("dup2 of stdin failed"); + _exit (1); + } r = system (pipecmd); if (r == -1) { @@ -770,9 +779,16 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd) _exit (WEXITSTATUS (r)...
2015 Dec 02
0
Re: [PATCH] daemon: improve internal commandrvf
...quest chroot for the process, which is done only as > very last (before chdir) operation before exec'ing the process in the > child: this avoids using CHROOT_IN & CHROOT_OUT around command* > invocations, and reduces the code spent in chroot mode > - add failure checks for dup2 and open done in child, not proceeding to > executing the process if they fail > - open /dev/null without O_CLOEXEC, so it stays available for the > exec'ed process, and thus we don't need to provide an own fd for stdin > > Followup of commit fd2f175ee79d29df101d353e2f38...
2006 Jan 03
2
Bug ? on ssh-agent
...ng openssh 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...
2004 Aug 25
2
[patch] sshd with re-exec disabled causes stdin to get closed.
...child closes stdin by accident. This causes FD 0 to get re-used by the next open call which eventually you end up with a mess. In the perticual case I saw, the pty fd ended up on FD 0 was closed by do_exec_pty(), pty_make_controlling_tty() then opened a new ttyfd as 0, and do_exec_pty() duped it dup2(0,0), dup2(0,1), dup2(0,2), then called close(ttyfd); which closed 0! Patch against openssh-3.9p1 is attached. -- Dave
2012 Dec 13
2
[PATCH 1/2] daemon: NFC Use symbolic names in commandrvf
...nor. * This is so we can ignore this device from the point of view of the * user, eg. in guestfs_list_devices and many other places. @@ -834,22 +838,22 @@ commandrvf (char **stdoutput, char **stderror, int flags, signal (SIGPIPE, SIG_DFL); close (0); if (flag_copy_stdin) { - dup2 (stdin_fd[0], 0); - close (stdin_fd[0]); - close (stdin_fd[1]); + dup2 (stdin_fd[PIPE_READ], STDIN_FILENO); + close (stdin_fd[PIPE_READ]); + close (stdin_fd[PIPE_WRITE]); } else { /* Set stdin to /dev/null (ignore failure) */ ignore_value (open ("/de...
2016 Jan 17
1
[PATCH klibc] run-init: Add dry-run mode
...+ return "overmounting root"; + } /* chroot, chdir */ if (chroot(".") || chdir("/")) @@ -205,12 +207,22 @@ const char *run_init(const char *realroo /* Open /dev/console */ if ((confd = open(console, O_RDWR)) < 0) return "opening console"; - dup2(confd, 0); - dup2(confd, 1); - dup2(confd, 2); - close(confd); - - /* Spawn init */ - execv(init, initargs); - return init; /* Failed to spawn init */ + if (!dry_run) { + dup2(confd, 0); + dup2(confd, 1); + dup2(confd, 2); + close(confd); + + /* Spawn init */ + execv(init, initargs); + retu...
2012 Mar 12
0
ssh shell spawn
...I've coded a shell that works with pipes, it opens 2 fds for each std (you can see code at the end) and so the communication can be transferred to the client end point, the server side and to the log file. My goal is to patch it into ssh, but for that I need to locate where the ssh dups (with dup2() the 0,1 and 2 fds with the client socket fd (I guess it does like this, I've no another idea without pipes, but I've read do_exec() and nothing about pipes, so... how can it be possible if not like this way?) for the best working of the application. Basically I want to know where can I p...
2009 Oct 30
2
More dovecot-2.0.alpha2 problems
...uffer_get_modifiable_data((array)->arr.buffer, NULL); \ elem != CONST_PTR_OFFSET(*(array)->v, (array)->arr.buffer- >used); \ (elem)++) #endif 2. Sometimes I see a flood of these errors in the log: [...] Fri Oct 30 14:45:23 server dovecot[9585]: imap: service(imap): dup2s failed Fri Oct 30 14:45:23 server dovecot[9585]: imap-login: Login: user=<userX>, method=PLAIN, rip=192.168.1.8, lip=192.168.1.7, pid=11362 Fri Oct 30 14:45:23 server dovecot[9585]: imap(pid 11362 user userX): Connection closed bytes=118/934 Fri Oct 30 14:45:23 server dovecot[9585]: im...
2005 Dec 13
3
is my initramdisk right? also getting ''Error opening /dev/console'' error
...6.12.6-xenU ? The man page of mkinitrd doesn''t tell much about the kernel-version. I however created different ramdisks using different kernel versions. 2.6.12.6-xen, 2.6.12.6-xen0, 2.6.12.6-xenU. Each time I however get the following common error: ERROR opening /dev/console!!!!: 2 error dup2''ing fd of 0 to 0 error dup2''ing fd of 0 to 1 error dup2''ing fd of 0 to 2 unmounting old /proc unmounting old /sys WARNING: can''t access (null) exec of init ((null)) failed!!!: 14 Kernel panic - not syncing: Attempted to kill init! With initrd image 2.6.12.6-xenU...
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
2002 Dec 21
6
[PATCH] PAM chauthtok + Privsep
...IGCHLD, SIG_DFL); + + ttyfd = mm_receive_fd(socket); + debug3("%s: ttyfd=%d, ttyname=%s", __func__, ttyfd, ttyname(ttyfd)); + + if ((pid = fork()) == 0) { + /* acquire controlling tty */ + pty_make_controlling_tty(ttyfd, ttyname(ttyfd)); + + /* set up stdin, stdout and stderr */ + if (dup2(ttyfd, 0) < 0) + error("dup2 stdin: %s", strerror(errno)); + if (dup2(ttyfd, 1) < 0) + error("dup2 stdout: %s", strerror(errno)); + if (dup2(ttyfd, 2) < 0) + error("dup2 stderr: %s", strerror(errno)); + + /* close extra descriptors */ + close(socket)...
2010 Dec 13
3
Slow I/O on ocfs2 file system
Hello, I have found, that ocfs2 is very slow when doing I/O operation without cache. See a simple test: ng-vvv1:~# dd if=/data/verejna/dd-1G bs=1k | dd of=/dev/null 1048576+0 records in 1048576+0 records out 1073741824 bytes (1.1 GB) copied, 395.183 s, 2.7 MB/s 2097152+0 records in 2097152+0 records out 1073741824 bytes (1.1 GB) copied, 395.184 s, 2.7 MB/s The underlying block device is quite
2013 Nov 22
4
[PATCH 0/2] libxl/xl: two more coverity related fixes
The first patch is a leftover from the switch to libxl__create_qemu_logfile, and while there it also handles possible errors when opening /dev/null. The second one is a fix for the issues present in do_daemonize. Thanks, Roger.
2016 Jun 25
1
Fwd: "Make_passthrough: pid XXXX, dup2(6, 0) failed" with LPRNG 3.8.C and Samba 4.3.8 on FreeBSD
...ot executed). In the Log, I get entries like 2016-06-25-12:39:16.710 wagi-util [4827] (Server) pdf: Trim_status_file: ' status.pr' max 10, min 0, size 6197 2016-06-25-12:39:16.710 wagi-util [4827] (Server) pdf: Wait_for_subserver: pid_to_wait_for -1, flags 1 *Make_passthrough: pid 4829, dup2(6,0) failed*2016-06-25-12:39:16.712 wagi-util [4828] (Worker - Print) pdf: Wait_for_pid: returning 'JFAIL', exit status 'exit status 32 (JFAIL)' 2016-06-25-12:39:16.712 wagi-util [4828] (Worker - Print) pdf: setstatus: msg 'IF filter 'pdflpd' filter exit status 'JF...
2002 Feb 04
1
forkoff()
...send(); } } if (detach) { /* * There should be a chan_wont_read()/chan_wont_write() * API, differing only in the debug messages used. */ chan_read_failed(c); chan_write_failed(c); channel_close_fds(c); fd = open(_PATH_DEVNULL, O_RDWR, 0); if (fd < 0) return; (void) dup2(fd, STDIN_FILENO); (void) dup2(fd, STDOUT_FILENO); (void) dup2(fd, STDERR_FILENO); if (fd > 2) (void) close(fd); (void) setsid(); } } -- -DISCLAIMER: an automatically appended disclaimer may follow. By posting- -to a public e-mail mailing list I hereby grant permission to distribute...
2016 Jan 21
0
[PATCH v3 2/6] daemon: Split out command() functions and CLEANUP_* macros into separate files.
...abort (); + } + + pid = fork (); + if (pid == -1) { + error (0, errno, "fork"); + abort (); + } + + if (pid == 0) { /* Child process running the command. */ + signal (SIGALRM, SIG_DFL); + signal (SIGPIPE, SIG_DFL); + close (0); + if (flag_copy_stdin) { + if (dup2 (flag_copy_fd, STDIN_FILENO) == -1) { + perror ("dup2/flag_copy_fd"); + _exit (EXIT_FAILURE); + } + } else { + /* Set stdin to /dev/null. */ + if (open ("/dev/null", O_RDONLY) == -1) { + perror ("open: /dev/null"); + _exit...
2020 Apr 04
0
[nbdkit PATCH 2/2] server: Sanitize stdin/out before running plugin code
...;/dev/null", O_RDONLY); - open ("/dev/null", O_WRONLY); - - /* If not verbose, set stderr to the same as stdout as well. */ + /* By this point, stdin/out have been redirected to /dev/null. + * If not verbose, set stderr to the same as stdout as well. + */ if (!verbose) dup2 (1, 2); diff --git a/server/captive.c b/server/captive.c index 0a243d2b..1ff10192 100644 --- a/server/captive.c +++ b/server/captive.c @@ -1,5 +1,5 @@ /* nbdkit - * Copyright (C) 2019 Red Hat Inc. + * Copyright (C) 2019-2020 Red Hat Inc. * * Redistribution and use in source and binary forms,...
2019 Jan 18
0
[klibc:master] run-init: Add dry-run mode
...ounting root"; + } /* chroot, chdir */ if (chroot(".") || chdir("/")) @@ -205,12 +207,24 @@ const char *run_init(const char *realroot, const char *console, /* Open /dev/console */ if ((confd = open(console, O_RDWR)) < 0) return "opening console"; - dup2(confd, 0); - dup2(confd, 1); - dup2(confd, 2); + if (!dry_run) { + dup2(confd, 0); + dup2(confd, 1); + dup2(confd, 2); + } close(confd); - /* Spawn init */ - execv(init, initargs); - return init; /* Failed to spawn init */ + if (!dry_run) { + /* Spawn init */ + execv(init, initargs); + r...