netatalk update from ianm@cit.nepean.uws.edu.au; Ian says:

This update implements changes to afpd (appletalk filing protocol daemon)
so that it handles users groups correctly for acess and handles the
effictive user and group of the parent process correctly under OpenBSD
2.5-beta. Previous fix didn't work quite as expected.
This commit is contained in:
marc 1999-03-31 22:51:00 +00:00
parent a8e6ee53ef
commit 4cf7d3a218
3 changed files with 110 additions and 73 deletions

View File

@ -3,7 +3,7 @@
# Version required: 1.4b2
# Date created: 8th January 1999
#
# $OpenBSD: Makefile,v 1.1.1.1 1999/01/19 04:40:13 marc Exp $
# $OpenBSD: Makefile,v 1.2 1999/03/31 22:51:00 marc Exp $
DISTNAME= netatalk-1.4b2
CATEGORIES= net print
@ -32,8 +32,13 @@ pre-configure:
@rm -f ${WRKSRC}/sys/netatalk/*.h
post-install:
@cp ${WRKSRC}/config/AppleVolumes.system /etc/netatalk
@cp ${WRKSRC}/config/AppleVolumes.default /etc/netatalk
@if [ ! -a X"/etc/netatalk/AppleVolumes.system" ]; then \
@cp ${WRKSRC}/config/AppleVolumes.system /etc/netatalk; \
fi
@if [ ! -a X"/etc/netatalk/Applevolumes.default" ]; then \
@cp ${WRKSRC}/config/AppleVolumes.default /etc/netatalk;\
fi
@chmod 750 /etc/netatalk
.include <bsd.port.mk>

View File

@ -202,76 +202,6 @@
struct ofork *of_alloc();
struct ofork *of_find();
+struct ofork *of_findfile();
--- etc/afpd/main.c.orig Tue Oct 22 08:44:48 1996
+++ etc/afpd/main.c Sun Oct 5 04:26:10 1997
@@ -19,6 +19,7 @@
#include <termios.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <strings.h>
#include <netdb.h>
#include <unistd.h>
@@ -265,22 +266,24 @@
}
}
+#ifdef ultrix
+ openlog( p, LOG_PID );
+#else ultrix
+ openlog( p, LOG_NDELAY|LOG_PID, LOG_DAEMON );
+#endif ultrix
+
if ( pidfile ) {
FILE *pf;
if (( pf = fdopen( pidfd, "w" )) == NULL ) {
- fprintf( stderr, "Can't fdopen pidfile!\n" );
+ syslog( LOG_ERR, "can't fdopen pidfile!" );
exit( 1 );
}
fprintf( pf, "%d\n", getpid());
fflush( pf );
}
-#ifdef ultrix
- openlog( p, LOG_PID );
-#else ultrix
- openlog( p, LOG_NDELAY|LOG_PID, LOG_DAEMON );
-#endif ultrix
+ of_init();
if (( status = (char *)malloc( ATP_MAXDATA )) == NULL ) {
syslog( LOG_ERR, "main: malloc: %m" );
@@ -526,28 +529,3 @@
status->as_flags |= AFPSRVRINFO_FASTBOZO;
status->as_flags = htons( status->as_flags );
}
-
-#ifdef notdef
-pdesc( f )
- FILE *f;
-{
- int i, o, d;
- extern int errno;
-
- d = getdtablesize();
-
- for ( i = 0; i < d; i++ ) {
- if ( ioctl( i, FIOGETOWN, &o ) < 0 ) {
- if ( errno == EBADF ) {
- fputs( "0", f );
- } else {
- fputs( "1", f );
- }
- } else {
- fputs( "1", f );
- }
- }
- fputs( "\n", f );
- fflush( f );
-}
-#endif notdef
--- etc/afpd/ofork.c.orig Sun Apr 21 00:26:36 1996
+++ etc/afpd/ofork.c Fri Apr 17 14:01:42 1998
@@ -1,10 +1,14 @@

View File

@ -0,0 +1,102 @@
--- etc/afpd/main.c.orig Tue Oct 22 08:44:48 1996
+++ etc/afpd/main.c Mon Mar 29 17:05:56 1999
@@ -19,6 +19,7 @@
#include <termios.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <strings.h>
#include <netdb.h>
#include <unistd.h>
@@ -53,6 +54,8 @@
char *Obj, *Type = "AFPServer", *Zone = "*";
char *version = VERSION;
ASP child;
+static int initial_uid;
+static int initial_gid;
extern struct oforks *writtenfork;
@@ -148,6 +151,10 @@
extern int optind;
umask( 0 ); /* so inherited file permissions work right */
+
+ initial_uid = geteuid();
+ initial_gid = getegid();
+
if ( gethostname( hostname, sizeof( hostname )) < 0 ) {
perror( "gethostname" );
exit( 1 );
@@ -265,22 +272,24 @@
}
}
+#ifdef ultrix
+ openlog( p, LOG_PID );
+#else ultrix
+ openlog( p, LOG_NDELAY|LOG_PID, LOG_DAEMON );
+#endif ultrix
+
if ( pidfile ) {
FILE *pf;
if (( pf = fdopen( pidfd, "w" )) == NULL ) {
- fprintf( stderr, "Can't fdopen pidfile!\n" );
+ syslog( LOG_ERR, "can't fdopen pidfile!" );
exit( 1 );
}
fprintf( pf, "%d\n", getpid());
fflush( pf );
}
-#ifdef ultrix
- openlog( p, LOG_PID );
-#else ultrix
- openlog( p, LOG_NDELAY|LOG_PID, LOG_DAEMON );
-#endif ultrix
+ of_init();
if (( status = (char *)malloc( ATP_MAXDATA )) == NULL ) {
syslog( LOG_ERR, "main: malloc: %m" );
@@ -360,7 +369,10 @@
exit( 1 );
}
- syslog( LOG_INFO, "session from %u.%u:%u on %u.%u:%u",
+ setuid(initial_uid); /* become our origional uid && gid again */
+ setgid(initial_uid);
+
+ syslog( LOG_INFO, "session from %u.%u:%u on %u.%u:%u",
ntohs( child->asp_sat.sat_addr.s_net ),
child->asp_sat.sat_addr.s_node, child->asp_sat.sat_port,
ntohs( atp_sockaddr( child->asp_atp )->sat_addr.s_net ),
@@ -526,28 +538,3 @@
status->as_flags |= AFPSRVRINFO_FASTBOZO;
status->as_flags = htons( status->as_flags );
}
-
-#ifdef notdef
-pdesc( f )
- FILE *f;
-{
- int i, o, d;
- extern int errno;
-
- d = getdtablesize();
-
- for ( i = 0; i < d; i++ ) {
- if ( ioctl( i, FIOGETOWN, &o ) < 0 ) {
- if ( errno == EBADF ) {
- fputs( "0", f );
- } else {
- fputs( "1", f );
- }
- } else {
- fputs( "1", f );
- }
- }
- fputs( "\n", f );
- fflush( f );
-}
-#endif notdef