utsname.c (435d5f4bb2ccba3b791d9ef61d2590e30b8e806e) utsname.c (3c0411846118a578de3a979faf2da3ab5fb81179)
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

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

83 struct uts_namespace *ns;
84
85 ns = container_of(kref, struct uts_namespace, kref);
86 put_user_ns(ns->user_ns);
87 proc_free_inum(ns->ns.inum);
88 kfree(ns);
89}
90
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

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

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