コード例 #1
0
ファイル: Startup.c プロジェクト: punktniklas/NiKom
void startupNiKom(void) {
  struct MsgPort *port;

  Forbid();
  port = (struct MsgPort *)FindPort("NiKomPort");
  if(port == NULL) {
    NiKPort = (struct MsgPort *)CreatePort("NiKomPort",0);
  }
  Permit();
  if(port != NULL) {
    printf("NiKServer is already running.\n");
    exit(10);
  }
  if(NiKPort == NULL) {
    printf("Can't create message port 'NiKomPort'\n");
    exit(10);
  }
  openLibrariesAndPorts();
  setupServermem();
  initLanguages();
  
  readSysInfo();
  readTextInfo();
  readGroupData();
  ReadCommandConfig();
  ReadSystemConfig();
  readConferenceData();
  readConferenceTexts();
  readUserData();
  ReadFidoConfig();
  ReadNodeTypesConfig();
  readLastLogins();
  ReadFileKeyConfig();
  ReadStatusConfig();
  readFileAreas();
  readFileAreaFiles();
  GetServerversion();
  scanFidoConferences();
  InitLegacyConversionData();
  initNodes();
  openWindow();
}
コード例 #2
0
int main(int argc, char **argv) {
	int maxLength = MAX_LENGTH_OF_DATA;
	char *username = (char *)malloc(maxLength * sizeof(char));
	char *password = (char *)malloc(maxLength * sizeof(char));
	char *correctPassword = (char *)malloc(maxLength * sizeof(char));
	char *encryptedPassword;


	if (argc < 2) {
		logMessage("ERR: Argument is missing");
		return 2;
	}

	// Read data from dovecot
	if (readUserData(username, password, maxLength) < 2) {
		logMessage("ERR: Reading account data failed");
		return 2;
	}

	// Check data against mysql
	if (proveUserData(username, correctPassword, maxLength) != 0) {
		logMessage("ERR: Database connection or SQL error.");
		return 1;
	}

#ifdef ENABLE_MD5
	// Salted MD5 hashs
	if (strlen(correctPassword) > 2 &&
		correctPassword[0] == 'M' &&
		correctPassword[1] == '$') {
		encryptedPassword = md5enc(password, strlen(password));
		logMessage("INFO: Password is salted md5 hash");
		password = encryptedPassword;
		correctPassword++; // Remove 'M'
	}

	if (index(correctPassword, '$') != NULL) {
#endif
		// Encrypt password from user, use correct password as configuration (salt)
		encryptedPassword = crypt(password, correctPassword);
		logMessage("INFO: Password is salted");
#ifdef ENABLE_MD5
	} else {
		// Encrypt password from user as md5
		encryptedPassword = md5enc(password, strlen(password));
		logMessage("INFO: Password is md5 hash");
	}
#endif

	// Check password against correct password.
	if (strlen(encryptedPassword) == strlen(correctPassword) &&
		strncmp(encryptedPassword, correctPassword, strlen(correctPassword)) == 0) {

		int status = 0;
		pid_t processId = fork();
		switch (processId) {
			case -1: // Failed
				 break;
			case 0: 
				setenv("AUTHORIZED", "2", 1);
				execl(argv[1], "");
				exit(0);
			default:
				wait(&status);
				logMessage("INFO: Login success");
				break;
		}
		return 0;
	}
        
	logMessage("ERR: Authentication failed");
	return 1;
}
コード例 #3
0
void ThreeGPPContentPlugin::findUserData(QFile *file, QContent *content)
{
    QString sig;
    bool valid = true;
    bool found_udta = false;
    qint32 jump = 0;

    while(!file->atEnd() && valid)
    {
        getHeaderBox(file, jump, sig, false);
        if (sig == "moov")                      //look in moov container
        {
            qint32 jump2 = 0;
            qint32 moovSize = 0;

            getHeaderBox(file, moovSize, sig, true);
            moovSize -= 8;
            while  ((moovSize -= jump2)  > 0)
            {
                getHeaderBox(file, jump2, sig, false);
                if (sig == "udta")
                {
                    found_udta = true;
                    break;
                }
                else if (sig == "trak")         //look in trak container
                {
                    qint32 trakSize = 0;
                    qint32 jump3 = 0;

                    getHeaderBox(file, trakSize, sig, true);
                    trakSize -= 8;
                    while ((trakSize -= jump3) > 0)
                    {
                        getHeaderBox(file, jump3, sig, false);
                        if (sig == "udta")
                        {
                            found_udta = true;
                        }
                        if (sig == "mdia")      //look in mdia container for audio only
                        {
                            qint32 mdiaSize = 0;
                            qint32 jump4 = 0;

                            getHeaderBox(file, mdiaSize, sig, true);
                            mdiaSize -= 8;
                            while ((mdiaSize -= jump4) > 0)
                            {
                                getHeaderBox(file, jump4, sig, false);

                                if( sig == "minf")  //look in minf container
                                {
                                    qint32 minfSize = 0;
                                    qint32 jump5 = 0;

                                    getHeaderBox(file, minfSize, sig, true);
                                    minfSize -= 8;
                                    while ((minfSize -= jump5) > 0)
                                    {
                                        getHeaderBox(file, jump5, sig, false);
                                        if(sig == "vmhd")       // has video
                                        {
                                            m_isAudioOnly = false;
                                            return;         //call off the search
                                        }
                                        skip(file, jump5);
                                    }
                                }
                                else
                                {
                                    skip(file, jump4);
                                }
                            }

                        }
                        else
                        {
                            skip(file, jump3);
                        }
                        if(found_udta)
                        {
                            readUserData(file, content);
                            return;
                        }
                    }
                }
                else
                {
                    skip(file, jump2);
                }

            }

            if(found_udta)
            {
               readUserData(file, content);
               return;
            }
            else
            {
                valid = false;
                break;
            }
        }
        else
        {
            skip(file, jump);
        }
     }
}
コード例 #4
0
//! Reads the next node
void CSceneLoaderIrr::readSceneNode(io::IXMLReader* reader, ISceneNode* parent,
	ISceneUserDataSerializer* userDataSerializer)
{
	if (!reader)
		return;

	scene::ISceneNode* node = 0;

	if (!parent && IRR_XML_FORMAT_SCENE==reader->getNodeName())
		node = SceneManager->getRootSceneNode();
	else if (parent && IRR_XML_FORMAT_NODE==reader->getNodeName())
	{
		// find node type and create it
		core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_NODE_ATTR_TYPE.c_str());

		node = SceneManager->addSceneNode(attrName.c_str(), parent);

		if (!node)
			os::Printer::log("Could not create scene node of unknown type", attrName.c_str());
	}
	else
		node=parent;

	// read attributes
	while(reader->read())
	{
		bool endreached = false;

		const wchar_t* name = reader->getNodeName();

		switch (reader->getNodeType())
		{
		case io::EXN_ELEMENT_END:
			if ((IRR_XML_FORMAT_NODE  == name) ||
				(IRR_XML_FORMAT_SCENE == name))
			{
				endreached = true;
			}
			break;
		case io::EXN_ELEMENT:
			if (IRR_XML_FORMAT_ATTRIBUTES == name)
			{
				// read attributes
				io::IAttributes* attr = FileSystem->createEmptyAttributes(SceneManager->getVideoDriver());
				attr->read(reader, true);

				if (node)
					node->deserializeAttributes(attr);

				attr->drop();
			}
			else
			if (IRR_XML_FORMAT_MATERIALS == name)
				readMaterials(reader, node);
			else
			if (IRR_XML_FORMAT_ANIMATORS == name)
				readAnimators(reader, node);
			else
			if (IRR_XML_FORMAT_USERDATA  == name)
				readUserData(reader, node, userDataSerializer);
			else
			if ((IRR_XML_FORMAT_NODE  == name) ||
				(IRR_XML_FORMAT_SCENE == name))
			{
				readSceneNode(reader, node, userDataSerializer);
			}
			else
			{
				os::Printer::log("Found unknown element in irrlicht scene file",
						core::stringc(name).c_str());
			}
			break;
		default:
			break;
		}

		if (endreached)
			break;
	}
	if (node && userDataSerializer)
		userDataSerializer->OnCreateNode(node);
}
コード例 #5
0
ファイル: bbs-setupfuncs.c プロジェクト: kincki/contiki
int userSetup(unsigned short drive) {
   unsigned short count=0,user_count=0;
   char input,buff[20];

   BBS_USER_REC mybbsuser;
   ST_FILE file;

   /* enter users */
   printf("\n* BBS user editor\n");

   strcpy(file.szFileName, "user.idx");
   file.ucDeviceNo = drive;

   if(siFileExists(&file) == 62 /*|| user_count == 0*/) {
     user_count = 1;
     memset(&mybbsuser, 0x20, sizeof(BBS_USER_REC));

     printf("\n* Initializing user databases...\n");
     strcpy(file.szFileName, "user.dat");
     ssInitRELFile(&file, &mybbsuser, sizeof(BBS_USER_REC), BBS_MAX_USERS);
     strcpy(file.szFileName, "user.idx");
     ssInitRELFile(&file, &user_count, sizeof(unsigned short), 1);
     writeUserIndex(&user_count, &file);
   }

   printf("\n(A)dd, (E)dit or (L)list users? ");
   input=getchar();

   switch (input) {

      case 'a':
      case 'A': {
          readUserIndex(&user_count, &file);
          enterUserData(&mybbsuser, &user_count);
          writeUserData(&mybbsuser, &file, &user_count);
          user_count += 1;
          writeUserIndex(&user_count, &file);
      }
      break;

      case 'e':
      case 'E': {
             printf("\n\nEnter user #: ");
             gets(buff);
             sscanf(buff, "%d", &count);
             readUserData(&mybbsuser, &file, &count);
             scrollScreen();
             printf("\nUser #     : %03d", count);
             printf("\nUsername   : %s", mybbsuser.user_name);
             printf("\nPassword   : %s\n", mybbsuser.user_pwd);
             printf("\nAccess lvl.: %03d\n", mybbsuser.access_req);
             enterUserData(&mybbsuser, &count);
             writeUserData(&mybbsuser, &file, &count);
      }
      break;

      case 'l':
      case 'L': {
             count = 1;
             scrollScreen();
             printf("\n\nID# |Acc. | Username");
             printf("\n----+-----+----------------------------");

             readUserIndex(&user_count, &file);

             do {
                readUserData(&mybbsuser, &file, &count);
                printf("\n%03d | %03d | %s",  count, mybbsuser.access_req, mybbsuser.user_name);
                count++;
             } while (count < user_count);

             printf("\n\nPress key"); 
             input=getchar();
      }   
      break;

   }
   return 0;
}