Exemple #1
0
static int
cio_ignore_proc_seq_show(struct seq_file *s, void *it)
{
    struct ccwdev_iter *iter;

    iter = it;
    if (!is_blacklisted(iter->ssid, iter->devno))
        /* Not blacklisted, nothing to output. */
        return 0;
    if (!iter->in_range) {
        /* First device in range. */
        if ((iter->devno == __MAX_SUBCHANNEL) ||
            !is_blacklisted(iter->ssid, iter->devno + 1))
            /* Singular device. */
            return seq_printf(s, "0.%x.%04x\n",
                      iter->ssid, iter->devno);
        iter->in_range = 1;
        return seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno);
    }
    if ((iter->devno == __MAX_SUBCHANNEL) ||
        !is_blacklisted(iter->ssid, iter->devno + 1)) {
        /* Last device in range. */
        iter->in_range = 0;
        return seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
    }
    return 0;
}
Exemple #2
0
static int sierra_probe(struct usb_serial *serial,
			const struct usb_device_id *id)
{
	int result = 0;
	struct usb_device *udev;
	u8 ifnum;

	udev = serial->dev;
	ifnum = sierra_interface_num(serial);

	/*
	 * If this interface supports more than 1 alternate
	 * select the 2nd one
	 */
	if (serial->interface->num_altsetting == 2) {
		dev_dbg(&udev->dev, "Selecting alt setting for interface %d\n",
			ifnum);
		/* We know the alternate setting is 1 for the MC8785 */
		usb_set_interface(udev, ifnum, 1);
	}

	if (is_blacklisted(ifnum,
				(struct sierra_iface_info *)id->driver_info)) {
		dev_dbg(&serial->dev->dev,
			"Ignoring blacklisted interface #%d\n", ifnum);
		return -ENODEV;
	}

	return result;
}
Exemple #3
0
void AppList::generateAppList()
{
    appLists.clear();

    // list all portable kde3 apps
    QDir kde3path( QDir::homePath() + "/.kde/share/apps");

    QByteArray kdehome = qgetenv("KDEHOME");
    if (kdehome.isEmpty())
        kdehome = QDir::homePath().toUtf8() + "/.kde4/";

    QDir kde4path( kdehome + "/share/apps");

    for (QStringListIterator it(kde3path.entryList()); it.hasNext();) {
        QByteArray app = QFile::encodeName(it.next());

        if (app[0] == '.')
            continue;

        qDebug() << "looking at" << app;

        bool blacklisted = is_blacklisted(app);
        if (blacklisted)
            continue;

        qDebug() << "candidate: " << app;
        AppListItem item;
        item.appName = app;
        item.dir = kde3path.path() + "/" + QFile::decodeName(app);
        appLists << item;
    }

}
Exemple #4
0
bool is_blacklisted(attributes::function_def const& f)
{
  if (is_blacklisted(f.return_type))
    return true;

  return std::any_of(f.parameters.cbegin(), f.parameters.cend(), [](attributes::parameter_def const& p) { return is_blacklisted(p.type); });
}
static int cio_check_devno_blacklisted(struct subchannel *sch)
{
	if (is_blacklisted(sch->schid.ssid, sch->schib.pmcw.dev)) {
		CIO_MSG_EVENT(6, "Blacklisted device detected "
			      "at devno %04X, subchannel set %x\n",
			      sch->schib.pmcw.dev, sch->schid.ssid);
		return -ENODEV;
	}
	return 0;
}
Exemple #6
0
static int cio_check_devno_blacklisted(struct subchannel *sch)
{
	if (is_blacklisted(sch->schid.ssid, sch->schib.pmcw.dev)) {
		/*
		 * This device must not be known to Linux. So we simply
		 * say that there is no device and return ENODEV.
		 */
		CIO_MSG_EVENT(6, "Blacklisted device detected "
			      "at devno %04X, subchannel set %x\n",
			      sch->schib.pmcw.dev, sch->schid.ssid);
		return -ENODEV;
	}
	return 0;
}
Exemple #7
0
void __print_func_entry(const char *func, const char *file)
{
	char tentabs[] = "\t\t\t\t\t\t\t\t\t\t"; // ten tabs and a \0
	char *ourtabs = &tentabs[10 - MIN(tab_depth, 10)];
	if (!printx_on)
		return;
	if (is_blacklisted(func))
		return;
	spin_lock_irqsave(&lock);
	__print_hdr();
	printk("%s%s() in %s\n", ourtabs, func, file);
	spin_unlock_irqsave(&lock);
	tab_depth++;
}
Exemple #8
0
void __print_func_entry(const char *func, const char *file)
{
	if (!print)
		return;
	if (is_blacklisted(func))
		return;
	spinlock_lock(&lock);
	printd("Vcore %2d", vcore_id());	/* helps with multicore output */
	for (int i = 0; i < tab_depth; i++)
		printf("\t");
	printf("%s() in %s\n", func, file);
	spinlock_unlock(&lock);
	tab_depth++;
}
Exemple #9
0
void __print_func_exit(const char *func, const char *file)
{
	if (!print)
		return;
	if (is_blacklisted(func))
		return;
	tab_depth--;
	spinlock_lock(&lock);
	printd("Vcore %2d", vcore_id());
	for (int i = 0; i < tab_depth; i++)
		printf("\t");
	printf("---- %s()\n", func);
	spinlock_unlock(&lock);
}
size_t rewriteHandlers(std::string &local, std::set<std::string> &handlersSets)
{
    HKEY localClassesKey = NULL;
    if (RegOpenKeyExA(HKEY_USERS, local.c_str(), 0, KEY_READ | KEY_WRITE, &localClassesKey) != ERROR_SUCCESS) {
        return 0;
    }
    size_t added = 0;
    std::set<std::string>::iterator hItr;
    for (hItr = handlersSets.begin(); hItr != handlersSets.end(); hItr++) {
        std::string handlerName = *hItr;
        if (is_blacklisted(handlerName)) {
            continue;
        }

        if (!key_exist(localClassesKey, handlerName.c_str()) ) {

            BYTE path_buffer[MAX_KEY_LENGTH];
            DWORD val_len = MAX_KEY_LENGTH;
            DWORD type;//RRF_RT_ANY
    
            std::string commandKey = handlerName + "\\shell\\open\\command";
            printf("+%s\n", commandKey.c_str());
            if (!read_key(HKEY_CLASSES_ROOT, commandKey, path_buffer, val_len, type)) {
                continue;
            }
            if (type != REG_SZ) {
                continue;
            }
            if (is_path_blacklisted((char*) path_buffer)) {
                printf("[BLACKLISTED] %s\n", path_buffer);
                continue;
            }
            //
            if (!write_key(localClassesKey, commandKey, path_buffer, val_len, type)) {
                continue;
            }
            printf("[+] %s\n", path_buffer);
            added++;

        } else {
            printf("Already exist: ");
            printf("%s\n", handlerName.c_str());
        }
    }
    RegCloseKey(localClassesKey);
    return added;
}
Exemple #11
0
/*
 * cio_validate_subchannel()
 *
 * Find out subchannel type and initialize struct subchannel.
 * Return codes:
 *   SUBCHANNEL_TYPE_IO for a normal io subchannel
 *   SUBCHANNEL_TYPE_CHSC for a chsc subchannel
 *   SUBCHANNEL_TYPE_MESSAGE for a messaging subchannel
 *   SUBCHANNEL_TYPE_ADM for a adm(?) subchannel
 *   -ENXIO for non-defined subchannels
 *   -ENODEV for subchannels with invalid device number or blacklisted devices
 */
int
cio_validate_subchannel (struct subchannel *sch, unsigned int irq)
{
	char dbf_txt[15];
	int ccode;

	sprintf (dbf_txt, "valsch%x", irq);
	CIO_TRACE_EVENT (4, dbf_txt);

	/* Nuke all fields. */
	memset(sch, 0, sizeof(struct subchannel));

	spin_lock_init(&sch->lock);

	/* Set a name for the subchannel */
	snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", irq);

	/*
	 * The first subchannel that is not-operational (ccode==3)
	 *  indicates that there aren't any more devices available.
	 */
	sch->irq = irq;
	ccode = stsch (irq, &sch->schib);
	if (ccode)
		return -ENXIO;

	/* Copy subchannel type from path management control word. */
	sch->st = sch->schib.pmcw.st;

	/*
	 * ... just being curious we check for non I/O subchannels
	 */
	if (sch->st != 0) {
		CIO_DEBUG(KERN_INFO, 0,
			  "Subchannel %04X reports "
			  "non-I/O subchannel type %04X\n",
			  sch->irq, sch->st);
		/* We stop here for non-io subchannels. */
		return sch->st;
	}

	/* Initialization for io subchannels. */
	if (!sch->schib.pmcw.dnv)
		/* io subchannel but device number is invalid. */
		return -ENODEV;

	/* Devno is valid. */
	if (is_blacklisted (sch->schib.pmcw.dev)) {
		/*
		 * This device must not be known to Linux. So we simply
		 * say that there is no device and return ENODEV.
		 */
		CIO_MSG_EVENT(0, "Blacklisted device detected "
			      "at devno %04X\n", sch->schib.pmcw.dev);
		return -ENODEV;
	}
	sch->opm = 0xff;
	chsc_validate_chpids(sch);
	sch->lpm = sch->schib.pmcw.pim &
		sch->schib.pmcw.pam &
		sch->schib.pmcw.pom &
		sch->opm;

	CIO_DEBUG(KERN_INFO, 0,
		  "Detected device %04X on subchannel %04X"
		  " - PIM = %02X, PAM = %02X, POM = %02X\n",
		  sch->schib.pmcw.dev, sch->irq, sch->schib.pmcw.pim,
		  sch->schib.pmcw.pam, sch->schib.pmcw.pom);

	/*
	 * We now have to initially ...
	 *  ... set "interruption subclass"
	 *  ... enable "concurrent sense"
	 *  ... enable "multipath mode" if more than one
	 *	  CHPID is available. This is done regardless
	 *	  whether multiple paths are available for us.
	 */
	sch->schib.pmcw.isc = 3;	/* could be smth. else */
	sch->schib.pmcw.csense = 1;	/* concurrent sense */
	sch->schib.pmcw.ena = 0;
	if ((sch->lpm & (sch->lpm - 1)) != 0)
		sch->schib.pmcw.mp = 1;	/* multipath mode */
	return 0;
}
Exemple #12
0
int main(int argc, char *argv[])
{
    auto log = std::unique_ptr<sammy::log>(new sammy::log());
    log->info("Starting server.");

    unsigned int request_id = 1;

    addrinfo* res = create_addrinfo();
    int sockfd = create_socket(res);
    
    set_socket_reusable(sockfd);
    set_socket_bind(sockfd, res);
    set_socket_non_blocking(sockfd);
    set_socket_listen(sockfd);
    
    int efd = create_epoll();

    set_epoll_interface(efd, sockfd);
    
    // Init the domain config loading
    auto domain_storage = std::make_shared<sammy::domain_storage>();
    if(domain_storage->errors())
    {
        log->error("Error loading config.");
        exit(1);
    }

    // Init cache
    auto cache = std::make_shared<sammy::cache_storage>();

    // Init events
    epoll_event* events = new epoll_event[MAX_EPOLL_EVENTS];

    sammy::thread::pool thread_pool;
    
    std::map<int, std::string> client_ip_address;

    log->info("Server started");

    while( true )
    {
        const int event_count = epoll_wait(efd, events, MAX_EPOLL_EVENTS, -1);

        for(int i = 0; i < event_count; ++i)
        {
            const epoll_event& event = events[i];
            
            if( (event.events & EPOLLERR) ||
                (event.events & EPOLLHUP) ||
                (!(event.events & EPOLLIN)))
            {
                std::cout << "Error in the file descriptor." << std::endl;
                close(event.data.fd);
                continue;
            }
            else if(sockfd == event.data.fd)
            {
                while( true )
                {
                    sockaddr_in cli_addr;
                    socklen_t clilen{ sizeof(cli_addr) };

                    // Accept the the request
                    int newsockfd = accept(sockfd, (sockaddr*)&cli_addr, &clilen);
                    if(newsockfd == -1)
                    {
                        break;
                    }

                    set_socket_non_blocking(sockfd);
                    set_epoll_interface(efd, newsockfd);
                    
                    std::string out;
                    inet_ntop(AF_INET, &(cli_addr.sin_addr), &out[0], INET_ADDRSTRLEN);
                    client_ip_address[newsockfd] = out;
                }
                
                continue;
            }
            else
            {
                int newsockfd = event.data.fd;
                
                std::string client_address = client_ip_address[newsockfd];
                
                std::string request_str = "";
                size_t read_result = 0;
                read_request(newsockfd, read_result, request_str);

                // If the read result isn't ok
                if(read_result == -1)
                {
                    log->error("Error in read result, error #" + std::to_string(errno));
                    close(newsockfd);
                    continue;
                }

                // The request string is empty
                if(request_str.empty())
                {
                    log->error("Request string empty.");
                    close(newsockfd);
                    continue;
                }

                // Parse request string
                auto client_request = std::make_shared<sammy::request>(request_id, request_str);
                if(client_request->errors())
                {
                    log->error("Request parse error: " + client_request->error_text());
                    close(newsockfd);
                    continue;
                }

                request_id++;
                
                // Load domain configuration
                std::string response = "";
                auto domain = domain_storage->get_domain(client_request->get_host());

                // If this server does not serve the domain being asked for, we close the connection.
                if(!domain)
                {
                    log->error(client_address + " : " + client_request->get_host() + " : " + client_request->get_method() + " : " + client_request->get_path() + " : Domain not served.");
                    close(newsockfd);
                    continue;
                }

                // If the client address is blacklisted, we close the connection.
                if(domain->is_blacklisted(client_address))
                {
                    log->error(client_address + " : " + client_request->get_host() + " : " + client_request->get_method() + " : " + client_request->get_path() + " : IP blacklisted.");
                    close(newsockfd);
                    continue;
                }

                // Add the task, to be processed by the thread pool when possible
                thread_pool.add_task(std::make_shared<sammy::thread::task>(newsockfd, domain, client_request, cache, client_address));
                
                continue;
            }
        }
    }

    delete [] events;

    return 0;
}
Exemple #13
0
void
gtk_inspector_python_init(void)
{
#ifdef ENABLE_PYTHON
    int res;
    struct sigaction old_sigint;

    if (is_blacklisted())
        return;

    /* This prevents errors such as "undefined symbol: PyExc_ImportError" */
    if (!dlopen(PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL))
    {
        g_error("%s\n", dlerror());
        return;
    }

    captured_stdout = g_string_new("");
    captured_stderr = g_string_new("");

    /* Back up and later restore SIGINT so Python doesn't steal it from us. */
    res = sigaction(SIGINT, NULL, &old_sigint);

    if (!Py_IsInitialized())
        Py_Initialize();

    res = sigaction(SIGINT, &old_sigint, NULL);

    Py_InitModule("gtk_inspector", gtk_inspector_python_methods);
    PyRun_SimpleString(
        "import gtk_inspector\n"
        "import sys\n"
        "\n"
        "class StdoutCatcher:\n"
        "    def write(self, str):\n"
        "        gtk_inspector.capture_stdout(str)\n"
        "\n"
        "class StderrCatcher:\n"
        "    def write(self, str):\n"
        "        gtk_inspector.capture_stderr(str)\n"
        "\n"
    );

    if (!pygobject_init(-1, -1, -1))
    {
        fprintf(stderr, "Error initializing pygobject support.\n");
        PyErr_Print();
        return;
    }

    char *argv[] = { "", NULL };
    PySys_SetArgv(0, argv);

    if (!PyImport_ImportModule("gi._gobject"))
      {
        PyErr_SetString(PyExc_ImportError, "could not import gi.gobject");
        return;
      }
    if (!PyImport_ImportModule("gi.repository"))
      {
        PyErr_SetString(PyExc_ImportError, "could not import gi.repository");
        return;
      }
    if (!PyImport_ImportModule("gi.repository.Gtk"))
      {
        PyErr_SetString(PyExc_ImportError, "could not import gtk");
        return;
      }

    python_enabled = TRUE;
#endif // ENABLE_PYTHON
}