Here’s a useful rc.local script which restores the optware (ipkg) functionality after an upgrade:
#!/bin/sh
#optware fixes http://forum.synology.com/enu/viewtopic.php?f=189&t=46095
mount -o bind /volume1/@optware /opt
# remount with noatime
mount -o remount,noatime /
mount -o remount,noatime /volume1
# enable debug spindown
syno_hibernate_debug_tool --enable 10
# Optware setup
[ -x /etc/rc.optware ] && /etc/rc.optware start
# configure ssh to run on 443
if ! grep "Port 443" /etc/ssh/sshd_config ; then
sed -i "s/Port 22/#Port 22/g" /etc/ssh/sshd_config
echo 'Port 443' >> /etc/ssh/sshd_config
/usr/syno/etc.defaults/rc.d/S95sshd.sh restart
fi
# restore /opt/bin path
if ! grep "/opt/bin" /root/.profile ; then
sed -i "s/PATH=/PATH=\/opt\/bin:/g" /root/.profile
fi
exit 0
I used the following files to let apache authenticate against the local /etc/passwd file.
The perl-pass.nl is used to generate a file based on the /etc/passwd and shadow file. You can place this in the crontab for example. Only the lower id’s are used, so root won’t be in the list.
The index.php reads from the passwd.html file generated by the perl script and will redirect the users to welcome.php when a correct password and username are used.
perl-pass.pl
#!/usr/bin/perl
#
open(PASSWD,"/etc/passwd");
open(SHADOW,"/etc/shadow");
open(FLATFILE,">/var/www/passwd.httpd");
while(<SHADOW>){
chop;
($uname,$temppass)=split(/:/);
$pass{$uname}=$temppass;
}
while(<PASSWD>){
chop;
($uname,$temppass,$uid,$gid,$fn,$homedir,$shell)=split(/:/);
if ($temppass ne 'x'){ $pass{$uname}=$temppass; }
if ($uid>=500) {
print FLATFILE
"$uname:$pass{$uname}:$uid:$gid:$fn:$homedir:$shell\n";
}
}
close(PASSWD);
close(SHADOW);
close(FLATFILE);
chmod(0644,"/var/www/passwd.httpd");
chown(65534,65534,"/var/www/passwd.httpd");
index.php
<? session_start() ?>
<html>
<body>
<p align="center"><br><br>
<br><br><b>Welcome to Server Manager</b>
</p>
<table align="center" border="0" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr><td>
<form method="POST" action="index.php">
Username: </td><td>
<input type="text" name="username" size="19"></td></tr>
<br>
<tr><td>Password: </td><td>
<input type="password" name="password" size="19"></td></tr>
<tr><td colspan="2" align="center">
<br><input type="submit" value="Login">
</form>
</td></tr>
</table>
</body>
</html>
<?
// Var
$user = ($_POST['username']);
$pass = ($_POST['password']);
$autharray = file("/var/www/passwd.httpd");
// Check passwd
for ($x = 0; $x < count($autharray); $x++)
{
if (eregi("^$user:", $autharray[$x])) {
$passwd = explode(":", $autharray[$x]);
$salt = substr($passwd[1],0,11);
$cryptpw = crypt($pass,$salt);
if ($cryptpw == $passwd[1]) {
// Succes
echo "<br><p align='center'>Username found on</p>";
echo "<br><p align='center'>Starting connection: $_SESSION[user]... Moment Please.....</p>";
$_SESSION['user'] = $user;
$_SESSION['server'] = $servername;
if ( $_SESSION['user'] == "admin" ) {
echo" <META HTTP-EQUIV='Refresh' CONTENT='1; URL=admin_overview.php'> ";
} else {
echo" <META HTTP-EQUIV='Refresh' CONTENT='1; URL=welcome.php'> ";
}
} else {
// Error on password
echo "<br><p align='center'>Wrong password or username!</p>";
}
}
}
?>
welcome.php
<? session_start() ?>
<?
if ( $_SESSION[user] == "" ) {
echo "No Access!";
} else {
echo "Welcome $_SESSION['user']</b><br><br>";
}
?>
If your synology NAS is slowing down your speed, you might want to give the following commands a try:
/usr/syno/etc/rc.d/S77synomkthumbd.sh stop
/usr/syno/etc/rc.d/S66synoindexd.sh stop
/usr/syno/etc/rc.d/S20pgsql.sh stop