Commit b9ec1a54 authored by Leigh Stoller's avatar Leigh Stoller

ZFS change; when ZFS_NOEXPORTS is on, we have to call exports_setup

when a user logs in so that their home directory and projects are exported
from ops. Otherwise things break.

Since we really do not want to do this too often, exports_setup is
exporting anyone who is logged in within the last week, and the web
interface is calling out to exports_setup only once a day for each user.

This can be "improved" but I am worried we are fighting a losing battle and
will eventually yank this code anyway.
parent c0f3a1f7
<?php
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -86,6 +86,8 @@ $BROWSER_CONSOLE_ENABLE = @BROWSER_CONSOLE_ENABLE@;
$IPV6_ENABLED = @IPV6_ENABLED@;
$IPV6_SUBNET_PREFIX = "@IPV6_SUBNET_PREFIX@";
$TBMAILTAG = $THISHOMEBASE;
$WITHZFS = @WITHZFS@;
$ZFS_NOEXPORT = @ZFS_NOEXPORT@;
$TBMAILADDR_OPS = "@TBOPSEMAIL_NOSLASH@";
$TBMAILADDR_WWW = "@TBWWWEMAIL_NOSLASH@";
......
<?php
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -922,14 +922,6 @@ function DOLOGIN($token, $password, $adminmode = 0, $nopassword = 0) {
}
$CHECKLOGIN_USER = $user;
#
# Usage stats.
#
DBQueryFatal("update user_stats set ".
" weblogin_count=weblogin_count+1, ".
" weblogin_last=now() ".
"where uid_idx='$uid_idx'");
# Clear IP record since we have a sucessful login from the IP.
if (isset($IP)) {
DBQueryFatal("delete from login_failures where IP='$IP'");
......@@ -991,6 +983,8 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null,
global $WIKISUPPORT, $WIKICOOKIENAME;
global $BUGDBSUPPORT, $BUGDBCOOKIENAME, $TRACSUPPORT, $TRACCOOKIENAME;
global $TBLIBEXEC_DIR, $EXP_VIS, $TBMAINSITE;
global $WITHZFS, $ZFS_NOEXPORT;
$flushtime = time() - 1000000;
# Caller makes these checks too.
......@@ -1113,6 +1107,32 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null,
" weblogin_failcount=0,weblogin_failstamp=0 ".
"where uid_idx='$uid_idx'");
#
# Ug. When using ZFS in NOEXPORT mode, we have to call exports_setup
# to get the mounts exported to back to boss. We do not want to do this
# every time the user logs in of course, and since exports_setup is
# using one week as its threshold, we can just do it on a daily basis.
#
$query_result =
DBQueryFatal("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'");
if (mysql_num_rows($query_result)) {
$lastrow = mysql_fetch_row($query_result);
$lastlogin = $lastrow[0];
if (time() - $lastlogin > (24 * 3600)) {
SUEXEC("nobody", "nobody", "webexports_setup", SUEXEC_ACTION_DIE);
}
}
#
# Usage stats.
#
DBQueryFatal("update user_stats set ".
" weblogin_count=weblogin_count+1, ".
" weblogin_last=now() ".
"where uid_idx='$uid_idx'");
# Proj-vis cookies
if ($EXP_VIS) {
setcookie("exp_vis_session", $opskey, 0, "/", $TBAUTHDOMAIN, 0);
......@@ -1252,8 +1272,6 @@ function NOLOGINS() {
}
function LASTWEBLOGIN($uid_idx) {
global $TBDBNAME;
$query_result =
DBQueryFatal("select weblogin_last from users as u ".
"left join user_stats as s on s.uid_idx=u.uid_idx ".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment