Exemple #1
0
Qmonthly::Qmonthly( QWidget * parent, Qt::WFlags f)
    : QDialog(parent, f)
{
#ifdef Q_WS_WIN
    path = QCoreApplication::applicationDirPath ();
#else
    path = "/usr/share/qsalat/";
#endif
    if (path.data()[path.size() - 1] != '/') path += "/";
    setupUi(this);
    setUI();
    setMethods();
#ifdef Q_WS_WIN
    file = path+"data/qsalat.xml";
#else
    file = QDir::homePath ()+"/.qsalat/config/qsalat.xml";
#endif
    parser.readFile(file);
    date = QDate::currentDate();
    prayers = new Qpray();
    init();
    setActions();
}
Exemple #2
0
static void
ReadConfigFile()
{
    FILE*           fp;
    char            buf[256], buf2[256];
    int             line;
    int             len;
    int             n, i, j;
    struct stat     sb;

    if ((fp = fopen(rfbAuthConfigFile, "r")) == NULL)
        return;

    if (fstat(fileno(fp), &sb) == -1) {
        FatalError("rfbAuthInit: ERROR: fstat %s: %s", rfbAuthConfigFile,
                   strerror(errno));
    }

    if ((sb.st_uid != 0) && (sb.st_uid != getuid())) {
        FatalError("ERROR: %s must be owned by you or by root\n",
                   rfbAuthConfigFile);
    }

    if (sb.st_mode & (S_IWGRP | S_IWOTH)) {
        FatalError("ERROR: %s cannot have group or global write permissions\n",
                   rfbAuthConfigFile);
    }

    rfbLog("Using auth configuration file %s\n", rfbAuthConfigFile);
    for (line = 0; fgets(buf, sizeof(buf), fp) != NULL; line++) {
        len = strlen(buf) - 1;
        if (buf[len] != '\n' && strlen(buf) == 256) {
            FatalError("ERROR in %s: line %d is too long!\n",
                       rfbAuthConfigFile, line + 1);
        }

        buf[len] = '\0';

        for (i = 0, j = 0; i < len; i++) {
            if (buf[i] != ' ' && buf[i] != '\t')
                 buf2[j++] = buf[i];
        }
        len = j;
        buf2[len] = '\0';
        if (len < 1) continue;

        if (!strcmp(buf2, "no-reverse-connections")) {
            rfbAuthDisableRevCon = TRUE;
            continue;
        }

        if (!strcmp(buf2, "no-remote-connections")) {
            interface.s_addr = htonl (INADDR_LOOPBACK);
            interface6 = in6addr_loopback;
            continue;
        }

        if (!strcmp(buf2, "no-clipboard-send")) {
            rfbAuthDisableCBSend = TRUE;
            continue;
        }

        if (!strcmp(buf2, "no-clipboard-recv")) {
            rfbAuthDisableCBRecv = TRUE;
            continue;
        }

#ifdef XVNC_AuthPAM
        if (!strcmp(buf2, "enable-user-acl")) {
            rfbAuthUserACL = TRUE;
            continue;
        }

        n = 17;
        if (!strncmp(buf2, "pam-service-name=", n)) {
            if (buf2[n] == '\0') {
                FatalError("ERROR in %s: pam-service-name is empty!",
                           rfbAuthConfigFile);
            }

            if ((pamServiceName = strdup(&buf2[n])) == NULL) {
                FatalError("rfbAuthInit strdup: %s", strerror(errno));
            }

            continue;
        }
#endif

        n = 23;
        if (!strncmp(buf2, "permitted-auth-methods=", n)) {
            if (buf2[n] == '\0') {
                FatalError("ERROR in %s: permitted-auth-methods is empty!",
                           rfbAuthConfigFile);
            }

            setMethods(&buf2[n]);
            continue;
        }

        n = 17;
        if (!strncmp(buf2, "max-idle-timeout=", n)) {
            int t;

            if (buf2[n] == '\0') {
                FatalError("ERROR in %s: max-idle-timeout is empty!",
                           rfbAuthConfigFile);
            }

            if (sscanf(&buf2[n], "%d", &t) < 1 || t <= 0) {
                FatalError("ERROR in %s: max-idle-timeout value must be > 0!",
                           rfbAuthConfigFile);
            }

            rfbMaxIdleTimeout = (CARD32)t;
            continue;
        }

        if (buf2[0] != '#')
            rfbLog("WARNING: unrecognized auth config line '%s'\n", buf);
    }

    fclose(fp);
}