SuExec-Useraccount einstellbar
bernd

bernd commited on 2010-03-17 17:24:32
Zeige 3 geänderte Dateien mit 39 Einfügungen und 2 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1705 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -214,6 +214,7 @@ $form .= "
214 214
 
215 215
 $ipaddrs = user_ipaddrs();
216 216
 $certs = user_certs();
217
+$available_users = available_suexec_users();
217 218
 
218 219
 $form .= "
219 220
 <h4 style=\"margin-top: 3em;\">Erweiterte Optionen</h4>
... ...
@@ -245,6 +246,19 @@ $form .= "
245 246
       ".html_select('ipv4', $ipselect, $vhost['ipv4'])."
246 247
       </div>";
247 248
   } 
249
+  if (count($available_users))
250
+  {
251
+    $userselect = array(0 => 'Eigener Benutzeraccount');
252
+    foreach ($available_users AS $u)
253
+    {
254
+      $userselect[$u['uid']] = $u['username'];
255
+    }
256
+    $form .= "
257
+      <h5>SuExec-Benutzeraccount</h5>
258
+      <div style=\"margin-left: 2em;\">
259
+      ".html_select('suexec_user', $userselect, $vhost['suexec_user'])."
260
+      </div>";
261
+  }
248 262
 $checked = ($vhost['autoipv6'] == 1) ? ' checked="checked"' : '';
249 263
 $form .= '<h5>IPv6</h5>
250 264
 <div style="margin-left: 2em;">
... ...
@@ -32,6 +32,7 @@ function empty_vhost()
32 32
   $vhost['php'] = 'php53';
33 33
   $vhost['cgi'] = 1;
34 34
   $vhost['ssl'] = NULL;
35
+  $vhost['suexec_user'] = NULL;
35 36
   $vhost['logtype'] = NULL;
36 37
   $vhost['errorlog'] = 0;
37 38
   $vhost['is_dav'] = 0;
... ...
@@ -212,6 +213,13 @@ function save_vhost($vhost)
212 213
   $php = maybe_null($vhost['php']);
213 214
   $cgi = ($vhost['cgi'] == 1 ? 1 : 0);
214 215
   $ssl = maybe_null($vhost['ssl']);
216
+  $suexec_user = 'NULL';
217
+
218
+  $available_suexec = available_suexec_users();
219
+  foreach ($available_suexec AS $u)
220
+    if ($u['uid'] == $vhost['suexec_user'])
221
+      $suexec_user = $u['uid'];
222
+
215 223
   $logtype = maybe_null($vhost['logtype']);
216 224
   $errorlog = (int) $vhost['errorlog'];
217 225
   if ($vhost['is_svn']) {
... ...
@@ -241,11 +249,11 @@ function save_vhost($vhost)
241 249
 
242 250
   if ($id != 0) {
243 251
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
244
-    db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1");
252
+    db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, `suexec_user`={$suexec_user}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1");
245 253
   }
246 254
   else {
247 255
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
248
-    $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
256
+    $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, `suexec_user`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$suexec_user}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
249 257
     $id = mysql_insert_id();
250 258
   }
251 259
   $oldvhost = get_vhost_details($id);
... ...
@@ -319,6 +327,18 @@ function save_alias($alias)
319 327
 }
320 328
 
321 329
 
330
+function available_suexec_users()
331
+{
332
+  $uid = (int) $_SESSION['userinfo']['uid'];
333
+  $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
334
+  $ret = array();
335
+  while ($i = mysql_fetch_assoc($result))
336
+    $ret[] = $i;
337
+  DEBUG('available suexec-users:');
338
+  DEBUG($ret);
339
+  return $ret;
340
+
341
+}
322 342
 
323 343
 
324 344
 function user_ipaddrs()
... ...
@@ -75,6 +75,9 @@ if ($_GET['action'] == 'edit')
75 75
     $cgi = 1;
76 76
   }
77 77
 
78
+  if (isset($_POST['suexec_user']))
79
+    $vhost['suexec_user'] = $_POST['suexec_user'];
80
+
78 81
   if ($_POST['vhost_type'] == 'regular') {
79 82
     $vhost['is_dav'] = 0;
80 83
     $vhost['is_svn'] = 0;
81 84