#include <atalk/logger.h>
#include <atalk/dsi.h>
-#include <netatalk/endian.h>
#include <atalk/util.h>
#define min(a,b) ((a) < (b) ? (a) : (b))
*
* 1. close the socket
* 2. set the DSI_DISCONNECTED flag
+ *
+ * @returns 0 if successfully entered disconnected state
+ * -1 if ppid is 1 which means afpd master died
+ * or euid == 0 ie where still running as root (unauthenticated session)
*/
int dsi_disconnect(DSI *dsi)
{
dsi->proto_close(dsi); /* 1 */
dsi->flags |= DSI_DISCONNECTED; /* 2 */
+ if (geteuid() == 0)
+ return -1;
return 0;
}
while (stored < length) {
len = buf_read(dsi, (u_int8_t *) data + stored, length - stored);
if (len == -1 && (errno == EINTR || errno == EAGAIN)) {
- LOG(log_debug, logtype_dsi, "dsi_stream_read: select read loop");
+ LOG(log_maxdebug, logtype_dsi, "dsi_stream_read: select read loop");
continue;
} else if (len > 0) {
stored += len;
} else { /* eof or error */
/* don't log EOF error if it's just after connect (OSX 10.3 probe) */
+ if (errno == ECONNRESET)
+ dsi->flags |= DSI_GOT_ECONNRESET;
if (len || stored || dsi->read_count) {
if (! (dsi->flags & DSI_DISCONNECTED)) {
LOG(log_error, logtype_dsi, "dsi_stream_read: len:%d, %s",