summaryrefslogtreecommitdiff
path: root/package/uhttpd/src
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-06 16:19:04 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-06 16:19:04 +0000
commit232ec2e0d27cf2d28abffa7b4e71198a6b40f75e (patch)
treead63c17608639e2dc145c5d89bb1d9f873e44674 /package/uhttpd/src
parentc9a09f81716586a3080159674e97c802d049c45f (diff)
[package] uhttpd: make it work without shadow password support
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@23897 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uhttpd/src')
-rw-r--r--package/uhttpd/src/Makefile6
-rw-r--r--package/uhttpd/src/uhttpd-utils.c9
-rw-r--r--package/uhttpd/src/uhttpd-utils.h5
3 files changed, 18 insertions, 2 deletions
diff --git a/package/uhttpd/src/Makefile b/package/uhttpd/src/Makefile
index 06d61bdef3..6dcc3555f1 100644
--- a/package/uhttpd/src/Makefile
+++ b/package/uhttpd/src/Makefile
@@ -13,6 +13,12 @@ LIB = -Wl,--export-dynamic -lcrypt -ldl
TLSLIB =
LUALIB =
+HAVE_SHADOW=$(shell echo 'int main(void){ return !getspnam("root"); }' | \
+ $(CC) -include shadow.h -xc -o/dev/null - 2>/dev/null && echo yes)
+
+ifeq ($(HAVE_SHADOW),yes)
+ CFLAGS += -DHAVE_SHADOW
+endif
world: compile
diff --git a/package/uhttpd/src/uhttpd-utils.c b/package/uhttpd/src/uhttpd-utils.c
index 3821eb54cb..9f9a5dd6a7 100644
--- a/package/uhttpd/src/uhttpd-utils.c
+++ b/package/uhttpd/src/uhttpd-utils.c
@@ -610,7 +610,10 @@ struct auth_realm * uh_auth_add(char *path, char *user, char *pass)
{
struct auth_realm *new = NULL;
struct passwd *pwd;
+
+#ifdef HAVE_SHADOW
struct spwd *spwd;
+#endif
if((new = (struct auth_realm *)malloc(sizeof(struct auth_realm))) != NULL)
{
@@ -625,6 +628,7 @@ struct auth_realm * uh_auth_add(char *path, char *user, char *pass)
/* given password refers to a passwd entry */
if( (strlen(pass) > 3) && !strncmp(pass, "$p$", 3) )
{
+#ifdef HAVE_SHADOW
/* try to resolve shadow entry */
if( ((spwd = getspnam(&pass[3])) != NULL) && spwd->sp_pwdp )
{
@@ -632,8 +636,11 @@ struct auth_realm * uh_auth_add(char *path, char *user, char *pass)
min(strlen(spwd->sp_pwdp), sizeof(new->pass) - 1));
}
+ else
+#endif
+
/* try to resolve passwd entry */
- else if( ((pwd = getpwnam(&pass[3])) != NULL) && pwd->pw_passwd &&
+ if( ((pwd = getpwnam(&pass[3])) != NULL) && pwd->pw_passwd &&
(pwd->pw_passwd[0] != '!') && (pwd->pw_passwd[0] != 0)
) {
memcpy(new->pass, pwd->pw_passwd,
diff --git a/package/uhttpd/src/uhttpd-utils.h b/package/uhttpd/src/uhttpd-utils.h
index 3514ce1cac..6a0a395a91 100644
--- a/package/uhttpd/src/uhttpd-utils.h
+++ b/package/uhttpd/src/uhttpd-utils.h
@@ -21,9 +21,12 @@
#include <stdarg.h>
#include <fcntl.h>
#include <pwd.h>
-#include <shadow.h>
#include <sys/stat.h>
+#ifdef HAVE_SHADOW
+#include <shadow.h>
+#endif
+
#define min(x, y) (((x) < (y)) ? (x) : (y))
#define max(x, y) (((x) > (y)) ? (x) : (y))