svn: /web/php-master/trunk/ include/functions.inc manage/users.php users.sql
| From: | David Soria Parra | Date: | Tue, 17 Jan 2012 09:34:04 +0000 |
| Subject: | svn: /web/php-master/trunk/ include/functions.inc manage/users.php users.sql | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-12822@lists.php.net to get a copy of this message | ||
dsp Tue, 17 Jan 2012 09:34:04 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=322385
Log:
Add rudimentary support for ssh keys
Changed paths:
U web/php-master/trunk/include/functions.inc
U web/php-master/trunk/manage/users.php
U web/php-master/trunk/users.sql
Modified: web/php-master/trunk/include/functions.inc
===================================================================
--- web/php-master/trunk/include/functions.inc 2012-01-17 09:30:12 UTC (rev 322384)
+++ web/php-master/trunk/include/functions.inc 2012-01-17 09:34:04 UTC (rev 322385)
@@ -183,3 +183,19 @@
return $mine;
}
+
+function verify_ssh_keys($string) {
+ return count(get_ssh_keys($string)) > 0;
+}
+
+function get_ssh_keys($string) {
+ $results = array();
+ if (preg_match_all('@(ssh-(?:rsa|dsa) ([^\s]+) ([^\s]*))@', $string, $matches,
PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $results[] = array('key' => $match[1],
+ 'name' => $match[3]);
+ }
+ }
+
+ return $results;
+}
Modified: web/php-master/trunk/manage/users.php
===================================================================
--- web/php-master/trunk/manage/users.php 2012-01-17 09:30:12 UTC (rev 322384)
+++ web/php-master/trunk/manage/users.php 2012-01-17 09:34:04 UTC (rev 322385)
@@ -141,6 +141,7 @@
. ($in[passwd] ? ",passwd='$in[passwd]'" : "")
. ($in[svnpasswd] ? ",svnpasswd='$in[svnpasswd]'" :
"")
. ($in[md5passwd] ? ",md5passwd='$in[md5passwd]'" :
"")
+ . ($in[sshkey] ? ",ssh_keys='$in[sshkey]'" : "")
. ((is_admin($user) && $in[username]) ?
",username='$in[username]'" : "")
. (is_admin($user) ? ",cvsaccess=$cvsaccess" : "")
. ",spamprotect=$spamprotect"
@@ -174,6 +175,7 @@
. ($in[passwd] ? ",passwd='$in[passwd]'" : "")
. ($in[svnpasswd] ? ",svnpasswd='$in[svnpasswd]'" :
"")
. ($in[md5passwd] ? ",md5passwd='$in[md5passwd]'" :
"")
+ . ($in[sshkey] ? ",ssh_keys='$in[sshkey]'" : "")
. (is_admin($user) ? ",cvsaccess=$cvsaccess" : "")
. ",spamprotect=$spamprotect"
. ",use_sa=$use_sa"
@@ -281,6 +283,10 @@
<td><input type="checkbox" name="in[verified]"<?php echo
$row[verified] ? " checked" : "";?> /> Note: Do not worry about this
value. It's sometimes used to check if old-timers are still around.</td>
</tr>
<tr>
+ <th align="right">SSH Key</th>
+ <td><textarea cols="50" rows="5"
name="in[sshkey]"><?php echo htmlspecialchars($row[ssh_keys])
?></textarea></td>
+</tr>
+<tr>
<th align="right">Add Note: </th>
<td><textarea cols="50" rows="5"
name="in[purpose]"></textarea></td>
</tr>
@@ -429,6 +435,10 @@
if ($in[rawpasswd] && $in[rawpasswd] != $in[rawpasswd2]) {
return "the passwords you specified did not match!";
}
+ if (isset($in[sshkey]) && !verify_ssh_keys($in[sshkey])) {
+ return "not a valid ssh key!";
+ }
+
return false;
}
Modified: web/php-master/trunk/users.sql
===================================================================
--- web/php-master/trunk/users.sql 2012-01-17 09:30:12 UTC (rev 322384)
+++ web/php-master/trunk/users.sql 2012-01-17 09:34:04 UTC (rev 322385)
@@ -43,6 +43,7 @@
greylist int(11) NOT NULL default '0',
enable int(1) NOT NULL default '0',
pchanged int(11) default '0',
+ ssh_keys TEXT default NULL,
PRIMARY KEY (userid),
UNIQUE KEY email (email),
UNIQUE KEY username (username),