Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 666220 Details for
Bug 872634
core_pattern helper not executed in same namespaces as crashing program
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
sample program to run setns from the command line
setns.c (text/x-csrc), 2.38 KB, created by
Neil Horman
on 2012-12-19 16:20:35 UTC
(
hide
)
Description:
sample program to run setns from the command line
Filename:
MIME Type:
Creator:
Neil Horman
Created:
2012-12-19 16:20:35 UTC
Size:
2.38 KB
patch
obsolete
>/* > * setns(1) - command-line interface for setns(2) > * > * Copyright (C) 2012 Neil Horman <nhorman@tuxdriver.com> > * > * This program is free software; you can redistribute it and/or modify it > * under the terms of the GNU General Public License as published by the > * Free Software Foundation; either version 2, or (at your option) any > * later version. > * > * This program is distributed in the hope that it will be useful, but > * WITHOUT ANY WARRANTY; without even the implied warranty of > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > * General Public License for more details. > * > * You should have received a copy of the GNU General Public License along > * with this program; if not, write to the Free Software Foundation, Inc., > * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > */ >#include <stdlib.h> >#include <stdio.h> >#include <limits.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> >#include <getopt.h> >#include <unistd.h> > > >struct option lopts[] = { > {"help", 0, NULL, 'h'}, > {"ipc", 1, NULL, 'i'}, > {"net", 1, NULL, 'n'}, > {"uts", 1, NULL, 'u'}, > {0, 0, 0, 0}, >}; > >static void usage(char **argv) >{ > printf("%s [--ipc|-i=<pid>] [--net|-n=pid] [--uts|-u=pid] <command>\n", > argv[0]); >} > >static int switch_namespace(const char *name, unsigned long pid) >{ > int fd; > char path[256]; > > sprintf(path, "/proc/%d/ns/%s", pid, name); > > fd = open(path, O_RDONLY); > if (fd < 0) > return -1; > > if (setns(fd, 0) < 0) { > perror("Setns failed: "); > return -1; > } > return 0; >} > >int main(int argc, char **argv) >{ > int opt; > int longind; > int execind = argc+1; > unsigned long pid; > int rc = 0; > > while ((opt = getopt_long(argc, argv, > "hi:n:u:", lopts, &longind)) != -1) { > > switch (opt) { > case '?': > usage(argv); > exit(0); > case 'h': > usage(argv); > exit(0); > > case 'i': > case 'n': > case 'u': > pid = strtoul(optarg, NULL, 10); > if (pid == ULONG_MAX) { > rc = 1; > printf("%s pid not properly specified\n", > lopts[longind].name); > goto out; > } > rc = switch_namespace(lopts[longind].name, pid); > if (rc < 0) { > printf("setns failed for %s\n", > lopts[longind].name); > goto out; > } > break; > > } > } > > if (optind == argc) { > printf("executable not properly specified\n"); > rc = 1; > goto out; > } > execind = optind; > >execute: > rc = execvp(argv[execind], &argv[execind]); > if (rc < 0) > perror("execv failed: "); >out: > return rc; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 872634
:
646534
|
646535
|
655182
| 666220