utsname.c (3c0411846118a578de3a979faf2da3ab5fb81179) utsname.c (64964528b24ea390824f0e5ce9d34b8d39b28cde)
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Author: Serge Hallyn <serue@us.ibm.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the

--- 79 unchanged lines hidden (view full) ---

88 kfree(ns);
89}
90
91static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
92{
93 return container_of(ns, struct uts_namespace, ns);
94}
95
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Author: Serge Hallyn <serue@us.ibm.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the

--- 79 unchanged lines hidden (view full) ---

88 kfree(ns);
89}
90
91static inline struct uts_namespace *to_uts_ns(struct ns_common *ns)
92{
93 return container_of(ns, struct uts_namespace, ns);
94}
95
96static void *utsns_get(struct task_struct *task)
96static struct ns_common *utsns_get(struct task_struct *task)
97{
98 struct uts_namespace *ns = NULL;
99 struct nsproxy *nsproxy;
100
101 task_lock(task);
102 nsproxy = task->nsproxy;
103 if (nsproxy) {
104 ns = nsproxy->uts_ns;
105 get_uts_ns(ns);
106 }
107 task_unlock(task);
108
109 return ns ? &ns->ns : NULL;
110}
111
97{
98 struct uts_namespace *ns = NULL;
99 struct nsproxy *nsproxy;
100
101 task_lock(task);
102 nsproxy = task->nsproxy;
103 if (nsproxy) {
104 ns = nsproxy->uts_ns;
105 get_uts_ns(ns);
106 }
107 task_unlock(task);
108
109 return ns ? &ns->ns : NULL;
110}
111
112static void utsns_put(void *ns)
112static void utsns_put(struct ns_common *ns)
113{
114 put_uts_ns(to_uts_ns(ns));
115}
116
113{
114 put_uts_ns(to_uts_ns(ns));
115}
116
117static int utsns_install(struct nsproxy *nsproxy, void *new)
117static int utsns_install(struct nsproxy *nsproxy, struct ns_common *new)
118{
119 struct uts_namespace *ns = to_uts_ns(new);
120
121 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
122 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
123 return -EPERM;
124
125 get_uts_ns(ns);
126 put_uts_ns(nsproxy->uts_ns);
127 nsproxy->uts_ns = ns;
128 return 0;
129}
130
118{
119 struct uts_namespace *ns = to_uts_ns(new);
120
121 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
122 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
123 return -EPERM;
124
125 get_uts_ns(ns);
126 put_uts_ns(nsproxy->uts_ns);
127 nsproxy->uts_ns = ns;
128 return 0;
129}
130
131static unsigned int utsns_inum(void *vp)
132{
133 return ((struct ns_common *)vp)->inum;
134}
135
136const struct proc_ns_operations utsns_operations = {
137 .name = "uts",
138 .type = CLONE_NEWUTS,
139 .get = utsns_get,
140 .put = utsns_put,
141 .install = utsns_install,
131const struct proc_ns_operations utsns_operations = {
132 .name = "uts",
133 .type = CLONE_NEWUTS,
134 .get = utsns_get,
135 .put = utsns_put,
136 .install = utsns_install,
142 .inum = utsns_inum,
143};
137};