Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
30c848ee
Commit
30c848ee
authored
Aug 13, 2015
by
Mike Hibler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deal with attempts to exploit the fact that we run as root and access files.
parent
88a4a831
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
11 deletions
+40
-11
apt/genilib-iocage.in
apt/genilib-iocage.in
+20
-7
apt/genilib-jail.in
apt/genilib-jail.in
+20
-4
No files found.
apt/genilib-iocage.in
View file @
30c848ee
...
...
@@ -333,8 +333,7 @@ if (system("mount -t nullfs -o ro $GENILIB $jailrootdir$GENILIB_MNT")) {
my
(
$j_ifile
,
$j_ofile
,
$j_pfile
);
if
(
$action
!=
1
)
{
my
$tempdir
=
"
/tmp/genilib/
";
if
(
!
mkdir
("
$jailrootdir$tempdir
",
0700
)
||
!
chown
(
$uid
,
$gid
,
"
$jailrootdir$tempdir
"))
{
if
(
!
mkdir
("
$jailrootdir$tempdir
",
0700
))
{
print
STDERR
"
Could not create geni-lib jail tempdir
\n
";
exit
(
1
);
}
...
...
@@ -346,14 +345,12 @@ if ($action != 1) {
msg
("
Stashing files
");
if
(
system
("
cp -p
$ifile
$jailrootdir$j_ifile
")
||
(
$pfile
&&
system
("
cp -p
$pfile
$jailrootdir$j_pfile
")))
{
(
$pfile
&&
system
("
cp -p
$pfile
$jailrootdir$j_pfile
"))
||
system
("
chown -R
$uid
:
$gid
$jailrootdir$tempdir
"))
{
print
STDERR
"
Could not populate jail
\n
";
exit
(
1
);
}
#
# XXX adjust the environment for the portal module to reflect the jail.
#
#
# XXX adjust the environment for the portal module to reflect the jail.
#
...
...
@@ -428,10 +425,26 @@ if ($status) {
}
if
(
$action
!=
1
)
{
if
(
system
("
cp -p
$jailrootdir$j_ofile
$ofile
"))
{
#
# Oh the joys of running as root. Now we need to take away user
# permission from the jail directory (recall the user can access
# it from outside) and then verify that the source file isn't a
# symlink (a cheap-o realpath check). Our caller is responsible
# for defending the target file.
#
my
$tempdir
=
"
/tmp/genilib
";
if
(
-
l
"
$jailrootdir$tempdir
"
||
chown
(
0
,
-
1
,
"
$jailrootdir$tempdir
")
!=
1
)
{
print
STDERR
"
Could not copy back results of command
\n
";
exit
(
1
);
}
if
(
-
e
"
$jailrootdir$j_ofile
")
{
if
(
-
l
"
$jailrootdir$j_ofile
"
||
system
("
cp
$jailrootdir$j_ofile
$ofile
"))
{
print
STDERR
"
Could not copy back results of command
\n
";
exit
(
1
);
}
}
}
else
{
print
STDERR
"
Jail '
$jailtag
' running. Root FS at '
$jailrootdir
'.
\n
";
}
...
...
apt/genilib-jail.in
View file @
30c848ee
...
...
@@ -321,8 +321,7 @@ if (system("mount -t nullfs -o ro $GENILIB $jailrootdir$GENILIB_MNT")) {
my
(
$j_ifile
,
$j_ofile
,
$j_pfile
);
if
(
$action
!=
1
)
{
my
$tempdir
=
"
/tmp/genilib/
";
if
(
!
mkdir
("
$jailrootdir$tempdir
",
0700
)
||
!
chown
(
$uid
,
$gid
,
"
$jailrootdir$tempdir
"))
{
if
(
!
mkdir
("
$jailrootdir$tempdir
",
0700
))
{
print
STDERR
"
Could not create geni-lib jail tempdir
\n
";
exit
(
1
);
}
...
...
@@ -334,7 +333,8 @@ if ($action != 1) {
msg
("
Stashing files
");
if
(
system
("
cp -p
$ifile
$jailrootdir$j_ifile
")
||
(
$pfile
&&
system
("
cp -p
$pfile
$jailrootdir$j_pfile
")))
{
(
$pfile
&&
system
("
cp -p
$pfile
$jailrootdir$j_pfile
"))
||
system
("
chown -R
$uid
:
$gid
$jailrootdir$tempdir
"))
{
print
STDERR
"
Could not populate jail
\n
";
exit
(
1
);
}
...
...
@@ -419,10 +419,26 @@ if ($status) {
}
if
(
$action
!=
1
)
{
if
(
system
("
cp -p
$jailrootdir$j_ofile
$ofile
"))
{
#
# Oh the joys of running as root. Now we need to take away user
# permission from the jail directory (recall the user can access
# it from outside) and then verify that the source file isn't a
# symlink (a cheap-o realpath check). Our caller is responsible
# for defending the target file.
#
my
$tempdir
=
"
/tmp/genilib
";
if
(
-
l
"
$jailrootdir$tempdir
"
||
chown
(
0
,
-
1
,
"
$jailrootdir$tempdir
")
!=
1
)
{
print
STDERR
"
Could not copy back results of command
\n
";
exit
(
1
);
}
if
(
-
e
"
$jailrootdir$j_ofile
")
{
if
(
-
l
"
$jailrootdir$j_ofile
"
||
system
("
cp
$jailrootdir$j_ofile
$ofile
"))
{
print
STDERR
"
Could not copy back results of command
\n
";
exit
(
1
);
}
}
}
else
{
print
STDERR
"
Jail '
$jailtag
' running. Root FS at '
$jailrootdir
'.
\n
";
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment