Beispiel #1
0
static void
remote_mobile_open (char *unix_sock_name, int from_tty)
{
  int source_fd;
  int md_fd;
  char *name;

  /* So first we have to get the file descriptor from our provider.  */
  source_fd = open_unix_socket (unix_sock_name);
  if (source_fd <= 0)
      error ("Could not open socket: %s to get mobile device file descriptor.", unix_sock_name);

  md_fd = receive_fd (source_fd);
  close (source_fd);

  if (md_fd < 0)
    error ("Could not get the mobile device fd - error: %d.\n", md_fd); 
     
  /* Now construct the file descriptor target name, and push the remote 
     target.  */
  
  name = malloc (strlen ("filedesc:") + 12);
  sprintf (name, "filedesc:%d", md_fd);
  push_remote_macosx_target (name, from_tty);

  /* Now that we've gotten the remote target, let's fix up a few things. */
  current_target.to_shortname = remote_mobile_shortname;
  current_target.to_longname = remote_mobile_longname;
  current_target.to_doc = remote_mobile_doc;
  
}
Beispiel #2
0
void
syslogd_enable(char const * ident, int log_facility,
        struct syslogd_options const * opt)
{
    // default rsyslogd
    if (opt == NULL) {
        openlog(ident, LOG_PID | LOG_CONS, 0);
        set_logger(vsyslogf);
        return;
    }

    // used configured rsyslogd
    bzero(syslogd_tag__, sizeof(syslogd_tag__));
    bzero(syslogd_pid__, sizeof(syslogd_pid__));

    snprintf(syslogd_pid__, sizeof(syslogd_pid__), "[%d]", getpid());
    if (getlogin_r(&syslogd_tag__[0], sizeof(syslogd_tag__)) < 0) {
        switch (errno) {
            case ENXIO: case ERANGE: case ENOTTY:
                errno = 0;
                break;
            default : DIE("getlogin_r error '%m'");
        }
    }

    SYSLOG_INFO__ = SYSLOG_TRACE__ =
        ((log_facility & LOG_FACMASK) | (LOG_INFO & LOG_PRIMASK));
    SYSLOG_WARNING__ =
        ((log_facility & LOG_FACMASK) | (LOG_WARNING & LOG_PRIMASK));
    SYSLOG_ERROR__ = SYSLOG_FATAL__ =
        ((log_facility & LOG_FACMASK) | (LOG_ERR & LOG_PRIMASK));

    if (opt->unix_socket)
        open_unix_socket(opt, ALL_TYPES);
    else
        open_inet_socket(opt, ALL_TYPES);

    set_logger(vslogf_rfc3164);
}
Beispiel #3
0
void
ResetWellKnownSockets () {
#ifdef UNIXCONN
	if (unixDomainConnection != -1) {
		/*
		 * see if the unix domain socket has disappeared
		 */
		struct stat	statb;

		if (stat (unsock.sun_path, &statb) == -1 ||
				(statb.st_mode & S_IFMT) != S_IFSOCK) {
			ErrorF ("Unix domain socket %s trashed, recreating\n",
					unsock.sun_path);
			(void) unlink (unsock.sun_path);
			(void) close (unixDomainConnection);
			WellKnownConnections &= ~(1L << unixDomainConnection);
			unixDomainConnection = open_unix_socket ();
			if (unixDomainConnection != -1)
				WellKnownConnections |= (1L << unixDomainConnection);
		}
	}
#endif /* UNIXCONN */
}
Beispiel #4
0
void
CreateWellKnownSockets() {
	int		request, i;
	int		whichbyte;	    /* used to figure out whether this is
   					 LSB or MSB */
#ifdef TCPCONN
	struct sockaddr_in insock;
	int		tcpportReg;	    /* port with same byte order as server */

#ifdef SO_LINGER
	static int linger[2] = { 0, 0 };
#endif /* SO_LINGER */

#endif /* TCPCONN */

#ifdef DNETCONN
	struct sockaddr_dn dnsock;
#endif /* DNETCONN */

#ifdef ISOCONN
	struct TSAPdisconnect tds;
	struct TSAPdisconnect *td = &tds;
	struct TSAPaddr tas;
	struct TSAPaddr *ta = &tas;
	struct PSAPaddr *pa;
	AEI   aei;
#endif /* ISOCONN */
	int retry;

#ifdef ISOCONN
#ifdef ISODEBUG
	isodetcpath = ISODEPATH;
#endif
#endif /* ISOCONN */

	CLEARBITS(AllSockets);
	CLEARBITS(AllClients);
	CLEARBITS(LastSelectMask);
	CLEARBITS(ClientsWithInput);

	for (i=0; i<MAXSOCKS; i++) ConnectionTranslation[i] = (ClientPtr)NULL;

#ifdef	hpux
	lastfdesc = _NFILE - 1;
#else
	lastfdesc = getdtablesize() - 1;
#endif	/* hpux */

	if (lastfdesc > MAXSOCKS) {
		lastfdesc = MAXSOCKS;
		if (debug_conns)
			ErrorF( "GOT TO END OF SOCKETS %d\n", MAXSOCKS);
	}

	WellKnownConnections = 0;
	whichbyte = 1;

	if (*(char *) &whichbyte)
		whichByteIsFirst = 'l';
	else
		whichByteIsFirst = 'B';


#ifdef TCPCONN

	tcpportReg = atoi (display);
	tcpportReg += X_TCP_PORT;

	if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
		Notice ("Creating TCP socket");
	} else {
		bzero ((char *)&insock, sizeof (insock));
		insock.sin_family = AF_INET;
		insock.sin_port = htons (tcpportReg);
		insock.sin_addr.s_addr = htonl(INADDR_ANY);
		retry = 20;
		while (i = bind(request, (struct sockaddr *) &insock, sizeof (insock))) {
#ifdef hpux
			/* Necesary to restart the server without a reboot */
			if (errno == EADDRINUSE)
				set_socket_option (request, SO_REUSEADDR);
			if (--retry == 0)
				Error ("Binding TCP socket");
			sleep (1);
#else
			if (--retry == 0)
				Error ("Binding MSB TCP socket");
			sleep (10);
#endif /* hpux */
		}
#ifdef hpux
		/* return the socket option to the original */
		if (errno)
			unset_socket_option (request, SO_REUSEADDR);
#endif /* hpux */
#ifdef SO_LINGER
		if(setsockopt (request, SOL_SOCKET, SO_LINGER,
					   (char *)linger, sizeof(linger)))
			Notice ("Setting TCP SO_LINGER\n");
#endif /* SO_LINGER */
		if (listen (request, 5))
			Error ("Reg TCP Listening");
		WellKnownConnections |= (1 << request);
		DefineSelf (request);
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}

#endif /* TCPCONN */

#ifdef UNIXCONN
	if ((request = open_unix_socket ()) != -1) {
		WellKnownConnections |= (1L << request);
		unixDomainConnection = request;
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}
#endif /*UNIXCONN */

#ifdef DNETCONN
	if ((request = socket (AF_DECnet, SOCK_STREAM, 0)) < 0) {
		Notice ("Creating DECnet socket");
	} else {
		bzero ((char *)&dnsock, sizeof (dnsock));
		dnsock.sdn_family = AF_DECnet;
		sprintf(dnsock.sdn_objname, "X$X%d", atoi (display));
		dnsock.sdn_objnamel = strlen(dnsock.sdn_objname);
		if (bind (request, (struct sockaddr *) &dnsock, sizeof (dnsock)))
			Error ("Binding DECnet socket");
		if (listen (request, 5)) Error ("DECnet Listening");
		WellKnownConnections |= (1 << request);
		DefineSelf (request);
#ifdef ISOCONN
		fd2family[request] = UNIX_IO;
#endif /* ISOCONN */
	}
#endif /* DNETCONN */
#ifdef ISOCONN
	/*
	 * If display is set, its the string after the Colon:
	 * i.e. X0 or X1 or T0 or T1...
	 */
	if ((display == NULLCP) || (atoi(display) == 0))
		aei = str2aei(TLocalHostName(), DEFAULTTSERVICE);
	else
		aei = str2aei(TLocalHostName(), display);

	if (aei == NULLAEI) {
		ErrorF("No AEI for me:");
		FatalError(TLocalHostName());
	}

	/*
	 * This hack only works if the PSAPaddr and SSAP addrsd are null!!
	 */
	if ((pa = aei2addr (aei)) == NULLPA)
		FatalError("address translation failed");

	ta = (struct TSAPaddr *)&(pa->pa_addr.sa_addr);

	/*
	 * Just put out a listen for now
	 */
	if ((request = TNetListen(ta, td)) != OK) {
		Error(TErrString(td->td_reason));
		FatalError("TNetListen");
	}

	WellKnownConnections |= (1 << request);
	DefineSelf (request);
	fd2family[request] = ISODE_IO;
#endif /*  ISOCONN */
	if (WellKnownConnections == 0)
		Error ("No Listeners, nothing to do");
	signal (SIGPIPE, SIG_IGN);
	signal (SIGHUP, AutoResetServer);
	signal (SIGINT, GiveUp);
	signal (SIGTERM, GiveUp);
	FirstClient = request + 1;
	AllSockets[0] = WellKnownConnections;
	ResetHosts(display);

	for (i=0; i<MaxClients; i++) {
		inputBuffers[i].buffer = (char *) NULL;
		inputBuffers[i].bufptr = (char *) NULL;
		inputBuffers[i].bufcnt = 0;
		inputBuffers[i].lenLastReq = 0;
		inputBuffers[i].size = 0;
	}
}