summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-11-28 16:34:31 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-01-20 10:27:55 +0100
commit2845394f72e2733f96621a1f02f1b943e62c0964 (patch)
tree72e7abf66c2aa212e4f7c5814a83a87a561a86eb
parent002b46da8a4270b89003a28b4f5431d857cd0b33 (diff)
trans: fix the receiver lookup in password
Use translation functions instead of doing the lookup manually. * trans/Makefile (password-MIGSFLAGS): Add mutators. * trans/password.c (S_password_check_user): Update accordingly. (S_password_check_group): Likewise.
-rw-r--r--trans/Makefile6
-rw-r--r--trans/password.c30
2 files changed, 23 insertions, 13 deletions
diff --git a/trans/Makefile b/trans/Makefile
index 291df2f3..c0386d08 100644
--- a/trans/Makefile
+++ b/trans/Makefile
@@ -1,6 +1,6 @@
#
# Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2006, 2007,
-# 2008 Free Software Foundation, Inc.
+# 2008, 2013 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -32,6 +32,10 @@ OBJS = $(SRCS:.c=.o) fsysServer.o ifsockServer.o passwordServer.o \
HURDLIBS = ports netfs trivfs iohelp fshelp pipe ihash shouldbeinlibc
LDLIBS += -lpthread
password-LDLIBS = $(LIBCRYPT)
+password-MIGSFLAGS=\
+ "-DIO_INTRAN=trivfs_protid_t trivfs_begin_using_protid (io_t)" \
+ "-DIO_DESTRUCTOR=trivfs_end_using_protid (trivfs_protid_t)" \
+ "-DPASSWORD_IMPORTS=import <hurd/trivfs.h>;"
include ../Makeconf
diff --git a/trans/password.c b/trans/password.c
index 6f15a9e8..344b78ba 100644
--- a/trans/password.c
+++ b/trans/password.c
@@ -1,5 +1,5 @@
/* Hurd standard password server.
- Copyright (C) 1999 Free Software Foundation
+ Copyright (C) 1999, 2013 Free Software Foundation
Written by Mark Kettenis.
The GNU Hurd is free software; you can redistribute it and/or
@@ -135,10 +135,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
/* Implement password_check_user as described in <hurd/password.defs>. */
kern_return_t
-S_password_check_user (io_t server, uid_t user, char *pw,
+S_password_check_user (struct trivfs_protid *cred, uid_t user, char *pw,
mach_port_t *port, mach_msg_type_name_t *port_type)
{
- struct trivfs_protid *cred;
struct ugids ugids = UGIDS_INIT;
auth_t auth;
error_t err;
@@ -150,10 +149,16 @@ S_password_check_user (io_t server, uid_t user, char *pw,
return strdup (pw);
}
- cred = ports_lookup_port (port_bucket, server, trivfs_protid_portclasses[0]);
if (! cred)
return EOPNOTSUPP;
+ if (cred->pi.bucket != port_bucket ||
+ cred->pi.class != trivfs_protid_portclasses[0])
+ {
+ ports_port_deref (cred);
+ return EOPNOTSUPP;
+ }
+
/* Verify password. */
err = ugids_add_user (&ugids, user, 1);
if (!err)
@@ -173,17 +178,14 @@ S_password_check_user (io_t server, uid_t user, char *pw,
}
ugids_fini (&ugids);
-
- ports_port_deref (cred);
return err;
}
/* Implement password_check_group as described in <hurd/password.defs>. */
kern_return_t
-S_password_check_group (io_t server, uid_t group, char *pw,
+S_password_check_group (struct trivfs_protid *cred, uid_t group, char *pw,
mach_port_t *port, mach_msg_type_name_t *port_type)
{
- struct trivfs_protid *cred;
struct ugids ugids = UGIDS_INIT;
auth_t auth;
error_t err;
@@ -195,10 +197,16 @@ S_password_check_group (io_t server, uid_t group, char *pw,
return strdup (pw);
}
- cred = ports_lookup_port (port_bucket, server, trivfs_protid_portclasses[0]);
if (! cred)
return EOPNOTSUPP;
-
+
+ if (cred->pi.bucket != port_bucket ||
+ cred->pi.class != trivfs_protid_portclasses[0])
+ {
+ ports_port_deref (cred);
+ return EOPNOTSUPP;
+ }
+
/* Verify password. */
err = ugids_add_gid (&ugids, group, 1);
if (!err)
@@ -218,7 +226,5 @@ S_password_check_group (io_t server, uid_t group, char *pw,
}
ugids_fini (&ugids);
-
- ports_port_deref (cred);
return err;
}