- if ( writtenfork ) {
- if ( flushfork( writtenfork ) < 0 ) {
- syslog( LOG_ERR, "main flushfork: %m" );
- }
- writtenfork = NULL;
- }
-#endif AFS
- func = (u_char) asp->commands[0];
- if ( obj->options.flags & OPTION_DEBUG ) {
- printf( "command: %d\n", func );
- bprint( asp->commands, asp->cmdlen );
- }
- if ( afp_switch[ func ] != NULL ) {
- /*
- * The function called from afp_switch is expected to
- * read its parameters out of buf, put its
- * results in replybuf (updating rbuflen), and
- * return an error code.
- */
- asp->datalen = ASP_DATASIZ;
- reply = (*afp_switch[ func ])(obj,
- asp->commands, asp->cmdlen,
- asp->data, &asp->datalen);
- } else {
- syslog( LOG_ERR, "bad function %X", func );
- asp->datalen = 0;
- reply = AFPERR_NOOP;
- }
- if ( obj->options.flags & OPTION_DEBUG ) {
- printf( "reply: %d, %d\n", reply, ccnt++ );
- bprint( asp->data, asp->datalen );
- }
-
- if ( asp_cmdreply( asp, reply ) < 0 ) {
- syslog( LOG_ERR, "asp_cmdreply: %m" );
- afp_asp_die(1);
- }
- break;
-
- case ASPFUNC_WRITE :
- func = (u_char) asp->commands[0];
- if ( obj->options.flags & OPTION_DEBUG ) {
- printf( "(write) command: %d\n", func );
- bprint( asp->commands, asp->cmdlen );
- }
- if ( afp_switch[ func ] != NULL ) {
- asp->datalen = ASP_DATASIZ;
- reply = (*afp_switch[ func ])(obj,
- asp->commands, asp->cmdlen,
- asp->data, &asp->datalen);
- } else {
- syslog( LOG_ERR, "(write) bad function %X", func );
- asp->datalen = 0;
- reply = AFPERR_NOOP;
- }
- if ( obj->options.flags & OPTION_DEBUG ) {
- printf( "(write) reply code: %d, %d\n", reply, ccnt++ );
- bprint( asp->data, asp->datalen );
- }
- if ( asp_wrtreply( asp, reply ) < 0 ) {
- syslog( LOG_ERR, "asp_wrtreply: %m" );
- afp_asp_die(1);
- }
- break;
- default:
- /*
- * Bad asp packet. Probably should have asp filter them,
- * since they are typically things like out-of-order packet.
- */
- syslog( LOG_INFO, "main: asp_getrequest: %d", reply );
- break;
- }
-
- if ( obj->options.flags & OPTION_DEBUG ) {
+ if ( writtenfork ) {
+ if ( flushfork( writtenfork ) < 0 ) {
+ LOG(log_error, logtype_afpd, "main flushfork: %s",
+ strerror(errno));
+ }
+ writtenfork = NULL;
+ }
+#endif /* AFS */
+ func = (u_char) asp->commands[0];
+#ifdef DEBUG1
+ if ( obj->options.flags & OPTION_DEBUG ) {
+ printf("command: %d (%s)\n", func, AfpNum2name(func));
+ bprint( asp->commands, asp->cmdlen );
+ }
+#endif
+ if ( afp_switch[ func ] != NULL ) {
+ /*
+ * The function called from afp_switch is expected to
+ * read its parameters out of buf, put its
+ * results in replybuf (updating rbuflen), and
+ * return an error code.
+ */
+ asp->datalen = ASP_DATASIZ;
+ reply = (*afp_switch[ func ])(obj,
+ asp->commands, asp->cmdlen,
+ asp->data, &asp->datalen);
+#ifdef FORCE_UIDGID
+ /* bring everything back to old euid, egid */
+ if (obj->force_uid)
+ restore_uidgid ( &obj->uidgid );
+#endif /* FORCE_UIDGID */
+ } else {
+ LOG(log_error, logtype_afpd, "bad function %X", func );
+ asp->datalen = 0;
+ reply = AFPERR_NOOP;
+ }
+#ifdef DEBUG1
+ if ( obj->options.flags & OPTION_DEBUG ) {
+ printf( "reply: %d, %d\n", reply, ccnt++ );
+ bprint( asp->data, asp->datalen );
+ }
+#endif
+ if ( asp_cmdreply( asp, reply ) < 0 ) {
+ LOG(log_error, logtype_afpd, "asp_cmdreply: %s", strerror(errno) );
+ afp_asp_die(EXITERR_CLNT);
+ }
+ break;
+
+ case ASPFUNC_WRITE :
+ func = (u_char) asp->commands[0];
+#ifdef DEBUG1
+ if ( obj->options.flags & OPTION_DEBUG ) {
+ printf( "(write) command: %d\n", func );
+ bprint( asp->commands, asp->cmdlen );
+ }
+#endif
+ if ( afp_switch[ func ] != NULL ) {
+ asp->datalen = ASP_DATASIZ;
+ reply = (*afp_switch[ func ])(obj,
+ asp->commands, asp->cmdlen,
+ asp->data, &asp->datalen);
+#ifdef FORCE_UIDGID
+ /* bring everything back to old euid, egid */
+ if (obj->force_uid)
+ restore_uidgid ( &obj->uidgid );
+#endif /* FORCE_UIDGID */
+ } else {
+ LOG(log_error, logtype_afpd, "(write) bad function %X", func );
+ asp->datalen = 0;
+ reply = AFPERR_NOOP;
+ }
+#ifdef DEBUG1
+ if ( obj->options.flags & OPTION_DEBUG ) {
+ printf( "(write) reply code: %d, %d\n", reply, ccnt++ );
+ bprint( asp->data, asp->datalen );
+ }
+#endif
+ if ( asp_wrtreply( asp, reply ) < 0 ) {
+ LOG(log_error, logtype_afpd, "asp_wrtreply: %s", strerror(errno) );
+ afp_asp_die(EXITERR_CLNT);
+ }
+ break;
+ default:
+ /*
+ * Bad asp packet. Probably should have asp filter them,
+ * since they are typically things like out-of-order packet.
+ */
+ LOG(log_info, logtype_afpd, "main: asp_getrequest: %d", reply );
+ break;
+ }
+#ifdef DEBUG1
+ if ( obj->options.flags & OPTION_DEBUG ) {