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
990a2933
Commit
990a2933
authored
Apr 17, 2017
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start using the new general/export_active sitevar to control when we
need to call exports_setup.
parent
89c6e499
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
49 deletions
+82
-49
db/Project.pm.in
db/Project.pm.in
+18
-11
db/User.pm.in
db/User.pm.in
+20
-15
www/tbauth.php3
www/tbauth.php3
+17
-13
xmlrpc/sslxmlrpc_server.py.in
xmlrpc/sslxmlrpc_server.py.in
+27
-10
No files found.
db/Project.pm.in
View file @
990a2933
#
!/usr/bin/perl -wT
#
#
Copyright
(
c
)
2005
-
201
6
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2005
-
201
7
University
of
Utah
and
the
Flux
Group
.
#
#
{{{
EMULAB
-
LICENSE
#
...
...
@@ -33,6 +33,7 @@ use vars qw(@ISA @EXPORT);
use
libdb
;
use
libtestbed
;
use
Brand
;
use
libEmulab
;
use
User
;
use
Group
;
use
English
;
...
...
@@ -950,6 +951,9 @@ sub UpdateExports($)
return
0
if
(
! ($WITHZFS && ($ZFS_NOEXPORT || !$WITHAMD)));
my
$
exports_limit
=
GetSiteVar
(
"general/export_active"
);
return
0
if
(
!$exports_limit);
my
$
query_result
=
DBQueryWarn
(
"select UNIX_TIMESTAMP(last_activity) from project_stats "
.
...
...
@@ -959,14 +963,15 @@ sub UpdateExports($)
if
(
!$query_result->numrows);
my
($
lastactivity
)
=
$
query_result
->
fetchrow_array
();
if
(
!defined($lastactivity) ||
time
()
-
$
lastactivity
>
(
24
*
3600
))
{
#
Update
last_activity
first
so
exports_setup
will
do
something
.
DBQueryWarn
(
"update project_stats set last_activity=now() "
.
"where pid_idx='$pid_idx'"
)
or
return
-
1
;
#
Update
last_activity
first
so
exports_setup
will
do
something
#
and
to
mark
the
project
as
active
,
to
keep
the
mount
active
.
DBQueryWarn
(
"update project_stats set last_activity=now() "
.
"where pid_idx='$pid_idx'"
)
or
return
-
1
;
if
(
!defined($lastactivity) ||
time
()
-
$
lastactivity
>
((($
exports_limit
*
24
)
-
12
)
*
3600
))
{
if
($
ZFS_NOEXPORT
)
{
mysystem
($
EXPORTS_SETUP
);
}
...
...
@@ -975,9 +980,11 @@ sub UpdateExports($)
}
#
failed
,
reset
the
timestamp
if
($?
&&
defined
($
lastactivity
))
{
DBQueryWarn
(
"update project_stats set "
.
" last_activity=FROM_UNIXTIME($lastactivity) "
.
if
($?)
{
my
$
set
=
(
defined
($
lastactivity
)
?
"FROM_UNIXTIME($lastactivity)"
:
"null"
);
DBQueryWarn
(
"update project_stats set last_activity=$set "
.
"where pid_idx='$pid_idx'"
);
return
-
1
;
}
...
...
db/User.pm.in
View file @
990a2933
...
...
@@ -31,6 +31,7 @@ use vars qw(@ISA);
use
emdb
;
use
EmulabConstants
;
use
libtestbed
;
use
libEmulab
;
use
Brand
;
use
English
;
use
Data
::
Dumper
;
...
...
@@ -2270,25 +2271,27 @@ sub UpdateExports($)
return
0
if
(
! ($WITHZFS && ($ZFS_NOEXPORT || !$WITHAMD)));
my
$
exports_limit
=
GetSiteVar
(
"general/export_active"
);
return
0
if
(
!$exports_limit);
my
$
query_result
=
DBQueryWarn
(
"select UNIX_TIMESTAMP(weblogin_last) from users as u "
.
"left join user_stats as s on s.uid_idx=u.uid_idx "
.
"where u.uid_idx='$uid_idx'"
);
DBQueryWarn
(
"select UNIX_TIMESTAMP(last_activity) from user_stats "
.
"where uid_idx='$uid_idx'"
);
#
Hmm
.
return
0
if
(
!$query_result->numrows);
my
($
lastlogin
)
=
$
query_result
->
fetchrow_array
();
if
(
!defined($lastlogin) ||
time
()
-
$
lastlogin
>
(
24
*
3600
))
{
#
Update
weblogin_last
first
so
exports_setup
will
do
something
.
DBQueryWarn
(
"update user_stats set "
.
" weblogin_last=now() "
.
"where uid_idx='$uid_idx'"
)
or
return
-
1
;
my
($
last_activity
)
=
$
query_result
->
fetchrow_array
();
#
Always
update
database
so
exports_setup
will
do
something
,
#
and
to
mark
activity
to
keep
mount
active
.
DBQueryWarn
(
"update user_stats set last_activity=now() "
.
"where uid_idx='$uid_idx'"
)
or
return
-
1
;
if
(
!defined($last_activity) ||
time
()
-
$
last_activity
>
((($
exports_limit
*
24
)
-
12
)
*
3600
))
{
if
($
ZFS_NOEXPORT
)
{
mysystem
($
EXPORTS_SETUP
);
}
...
...
@@ -2296,9 +2299,11 @@ sub UpdateExports($)
mysystem
($
EXPORTS_SETUP
.
" -B"
);
}
#
failed
,
reset
the
timestamp
if
($?
&&
defined
($
lastlogin
))
{
DBQueryWarn
(
"update user_stats set "
.
" weblogin_last=FROM_UNIXTIME($lastlogin) "
.
if
($?)
{
my
$
set
=
(
defined
($
last_activity
)
?
"FROM_UNIXTIME($last_activity)"
:
"null"
);
DBQueryWarn
(
"update user_stats set last_activity=$set "
.
"where uid_idx='$uid_idx'"
);
return
-
1
;
}
...
...
www/tbauth.php3
View file @
990a2933
...
...
@@ -1042,32 +1042,36 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null,
# every time the user logs in of course, and since exports_setup is
# using one week as its threshold, we can use that as the limit.
#
if
(
$WITHZFS
&&
$ZFS_NOEXPORT
)
{
$exports_active
=
TBGetSiteVar
(
"general/export_active"
);
if
(
$WITHZFS
&&
$ZFS_NOEXPORT
&&
$exports_active
)
{
$limit
=
((
$exports_active
*
24
)
-
12
)
*
3600
;
$query_result
=
DBQueryFatal
(
"select UNIX_TIMESTAMP(
weblogin_last),weblogin_last
"
.
DBQueryFatal
(
"select UNIX_TIMESTAMP(
last_activity),last_activity
"
.
" from users as u "
.
"left join user_stats as s on s.uid_idx=u.uid_idx "
.
"where u.uid_idx='
$uid_idx
' and "
.
" u.nonlocal_id is null"
);
# Update last_activity first so exports_setup will do something
# and to mark activity to keep the mount active.
DBQueryFatal
(
"update user_stats set last_activity=now() "
.
"where uid_idx='
$uid_idx
'"
);
if
(
mysql_num_rows
(
$query_result
))
{
$lastrow
=
mysql_fetch_row
(
$query_result
);
$last
login
=
$lastrow
[
0
];
$last
login
str
=
$lastrow
[
1
];
$lastrow
=
mysql_fetch_row
(
$query_result
);
$last
active
=
$lastrow
[
0
];
$last
active
str
=
$lastrow
[
1
];
if
(
time
()
-
$lastlogin
>
(
24
*
3600
*
6
))
{
# Update weblogin_last first so exports_setup
# will do something.
DBQueryFatal
(
"update user_stats set "
.
" weblogin_last=now() "
.
"where uid_idx='
$uid_idx
'"
);
if
(
time
()
-
$lastactive
>
$limit
)
{
$rv
=
SUEXEC
(
"nobody"
,
"nobody"
,
"webexports_setup"
,
SUEXEC_ACTION_IGNORE
);
# failed, reset the timestamp
if
(
$rv
)
{
DBQueryFatal
(
"update user_stats set "
.
"
weblogin_last='
$lastlogin
str
' "
.
"
last_activity='
$lastactive
str
' "
.
"where uid_idx='
$uid_idx
'"
);
SUEXECERROR
(
SUEXEC_ACTION_DIE
);
return
;
...
...
xmlrpc/sslxmlrpc_server.py.in
View file @
990a2933
#!/usr/local/bin/python
#
# Copyright (c) 2005-201
6
University of Utah and the Flux Group.
# Copyright (c) 2005-201
7
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -24,6 +24,7 @@
import
sys
import
getopt
import
os
,
os
.
path
import
time
import
pwd
import
traceback
import
syslog
...
...
@@ -312,6 +313,8 @@ class MyServer(SSL.ForkingSSLServer, SimpleXMLRPCDispatcher):
pass
def
setupuser
(
self
,
request
,
client
):
exports_active
=
TBGetSiteVar
(
"general/export_active"
);
subject
=
request
.
get_peer_cert
().
get_subject
()
if
self
.
debug
:
self
.
logit
(
str
(
subject
))
...
...
@@ -372,16 +375,30 @@ class MyServer(SSL.ForkingSSLServer, SimpleXMLRPCDispatcher):
# We have to make sure the exports are done, since the user might
# not be using the web interface at all.
#
if
WITHZFS
and
ZFS_NOEXPORT
:
res
=
DBQueryFatal
(
"select last_activity from user_stats as s "
"where uid_idx=%s and "
" last_activity < now() - (24 * 3600) "
,
if
WITHZFS
and
ZFS_NOEXPORT
and
exports_active
:
limit
=
((
int
(
exports_active
)
*
24
)
-
12
)
*
3600
res
=
DBQueryFatal
(
"select UNIX_TIMESTAMP(last_activity) "
" from user_stats "
"where uid_idx=%s"
,
(
str
(
self
.
uid_idx
),))
# Do not do this every time.
if
len
(
res
):
DBQueryFatal
(
"update user_stats set last_activity=now() "
"where uid_idx=%s "
,
(
str
(
self
.
uid_idx
),))
last_activity
=
int
(
res
[
0
][
0
])
self
.
logit
(
"%s: limit,last_activity for %s,%d: %d,%d,%d"
%
(
client
[
0
],
self
.
uid
,
self
.
uid_idx
,
limit
,
last_activity
,
int
(
time
.
time
())))
# Always update weblogin_last so exports_setup will do something,
# and to mark activity to keep mount active.
DBQueryFatal
(
"update user_stats set last_activity=now() "
"where uid_idx=%s"
,
(
str
(
self
.
uid_idx
),))
if
time
.
time
()
-
last_activity
>
limit
:
self
.
logit
(
"%s: calling exports_setup for %s,%d"
%
(
client
[
0
],
self
.
uid
,
self
.
uid_idx
))
if
os
.
system
(
TBDIR
+
"/sbin/exports_setup"
):
raise
Exception
(
"exports_setup failed"
)
pass
...
...
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