int			ft_expand_tilde(const char *src, char *refs[3], char **ptr)
{
	if (*src != '~')
		return (-1);
	else if (src[1] == '+')
		return (pwd(src, refs[1], ptr));
	else if (src[1] == '-')
		return (pwd(src, refs[2], ptr));
	else if (src[1] != '/' && src[1] != '\0')
		return (homeroot(src, refs[0], ptr));
	if (refs[0] == NULL)
		return (-1);
	return (home(src, refs[0], ptr));
}
示例#2
0
文件: lab1main.c 项目: konorati/CS360
int main()
{   int command_code = 0;
    initRoot();  // Initialize the '/' root directory of the tree
    cwd = root; // Set cwd to root
    while(command_code != 10)
    {
       printf("Enter a command or enter menu: ");
       getInput();
       command_code = findCommand();
       breakPathname();
      // printf("pathname = %s, command = %s, command code = %d, dirname = %s, basename = %s\n", pathname, command, command_code, dirname, basename); // For testing
       switch (command_code)
       {
          case 0: printMenu(); break;
          case 1: mkdir(); break;
          case 2: rmdir(); break;
          case 3: cd(); break;
          case 4: ls(); break;
          case 5: pwd(); break;
          case 6: creat(); break;
          case 7: rm(); break;
          case 8: save(); break;
          case 9: reload(); break;
          case 10: quit(); break;
          default: printf("Invalid command\n"); break;
       }
    }
   return 0;
}
示例#3
0
int executeIfBuildInSameShellCommand(Cmd c){
	//printf("checking for %s\n",c->args[0]);
	if (strcmp(c->args[0], LOGOUT) == 0) {
		exit(0);
	}
	if (strcmp(c->args[0], SETENV) == 0) {
		return executeSetEnv(c);
	}
	if (strcmp(c->args[0], UNSETENV) == 0) {
		return executeUnsetEnv(c);
	}
	if (strcmp(c->args[0], ECHO) == 0) {
		return executeEcho(c);
	}
	if (strcmp(c->args[0], WHERE) == 0) {
		return executeWhere(c);
	}
	if(strcmp(c->args[0],CD) == 0){
		return cd(c);
	}
	if (strcmp(c->args[0], PWD) == 0) {
		return pwd();
	}
	if (strcmp(c->args[0], NICE) == 0) {
		return executeNice(c);
	}
	return -1;
}
bool MaStoreConfigDialog::doUiDataExchange(bool fillUi)
{
	MaParentItem* rootItem = mStore->rootItem();

	Q_ASSERT(NULL != mStore);
	Q_ASSERT(rootItem);

	if (fillUi)
	{
		mUi.mStoreNameLineEdit->setText(rootItem->caption());
		mUi.mStoreDescriptionTextEdit->setText(rootItem->notes());
		mUi.mPasswordLineEdit->setText(rootItem->password());
		mUi.mPasswordConfirmLineEdit->setText(rootItem->password());
	}
	else
	{
		QString pwd(mUi.mPasswordLineEdit->text().trimmed());
		QString pwd2(mUi.mPasswordConfirmLineEdit->text().trimmed());
		if (pwd.compare(pwd2))
		{
			QMessageBox::warning(this, kAppName, "The two passwords do not match. Please try again.", QMessageBox::Ok);
			return false;
		}
		rootItem->setCaption(mUi.mStoreNameLineEdit->text().trimmed());
		rootItem->setNotes(mUi.mStoreDescriptionTextEdit->toPlainText().trimmed());
		rootItem->setPassword(pwd);
	}
	return true;
}
示例#5
0
int run_cmd(int argc, char **argv) {
	if (strcmp(argv[0],"echo")==0) {
			return echo(argc,argv);
	} else if (strcmp(argv[0],"cd")==0 || strcmp(argv[0],"chdir")==0) {
			return cd(argc,argv);
	} else if (strcmp(argv[0],"exit")==0) {
			fprintf(stderr,"exit\n");
			exit(0);
			return 0;
	} else if (strcmp(argv[0],"exec")==0) {
			return exec(argc,argv);
	} else if (strcmp(argv[0],"pushd")==0) {
			return pushd(argc,argv);
	} else if (strcmp(argv[0],"popd")==0) {
			return popd(argc,argv);
	} else if (strcmp(argv[0],"dirs")==0) {
			return dirs(argc,argv);
	} else if (strcmp(argv[0],"help")==0) {
			return help(argc,argv);
	} else if (strcmp(argv[0],"exitc")==0) {
			return exitc(argc,argv);
	} else if (strcmp(argv[0],"pwd")==0) {
			return pwd(argc,argv);
	} else if (strcmp(argv[0],"setpipe")==0) {
			return setpipe(argc,argv);
	} else if (strcmp(argv[0],"runpipe")==0) {
			return runpipe(argc,argv);
	} else {
			return run(argc,argv);
	}
}
示例#6
0
void handletextbox(muiObject *obj, enum muiReturnValue value)
{
    char *s, *slash;

    if (value != MUI_TEXTBOX_RETURN) return;
    s = muiGetTBString(obj);
    if (0 == chdir(s)) {
	pwd();
	ls();
	settlstrings(tl, filelist);
	selectedfile = 0;
	muiChangeLabel(l4, directory);
	muiClearTBString(obj);
	return;
    }
    /* hack up the path, if any */
    slash = strrchr(s, '/');
    if (slash == 0) {
	slash = s-1;	/* to make filename == slash+1 */
    } else {
	if (*s == '/') { /* absolute path */
	    strncpy(directory, s, slash-s);
	    directory[slash-s] = 0;
	} else {
	    strcat(directory, "/");
	    strncat(directory, s, slash-s);
	}
    }
     /* now filename == slash+1 */
    writeoutputfile(directory, slash+1);
    exit(0);
}
示例#7
0
文件: main.c 项目: russvick/CS360
main()
{
    initilize();

    while(1)
    {
        int id;

		// Read line from user, and get the function id from it
        GetLine();
        id = FindCommand();

        switch(id)
        {
            case 0:
                mkdir(pathname);
                break;
            case 1:
                rmdir(pathname);
                break;
            case 2:
                cd(pathname);
                break;
            case 3:
                ls();
                break;
            case 4:
                pwd();
                break;
            case 5:
                creat(pathname);
                break;
            case 6:
                rm(pathname);
                break;
            case 7:
                save();
                break;
            case 8:
                reload();
                break;
            case 9:
                menu();
                break;
            case 10:
                quit();
                break;
            default:
                printf("Command not recognized! Please try again.\n\n");
                break;
        }
    }




	return 0;
}
示例#8
0
文件: client.cpp 项目: tinnfu/ftp
int client::dispatch()
{
    char cmd_type =
        m_command_checker.get_command_type(m_cmd[0]);

    if( is_command_type(CMD_ERR, cmd_type) )
    {
        return -1;
    }

    int res = 0;

    switch(cmd_type)
    {
        case CMD_CLEAR:
            clear();
            break;

        case CMD_LS:
            res = ls();
            break;

        case CMD_CD:
            cd(m_cmd[1]);
            break;

        case CMD_CDLOCAL:
            cdlocal();
            break;

        case CMD_CDREMOTE:
            cdremote();
            break;

        case CMD_RM:
            break;

        case CMD_PWD:
            pwd();
            break;

        case CMD_EXIT:
            over();
            break;

        case CMD_UPLD:
            break;

        case CMD_DWLD:
            break;

        default:
            break;
    }


    return res;
}
示例#9
0
文件: lab2v11.c 项目: zeke225/cs360
/******* Lab2.c file *******/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include <libgen.h> //used for getting dirname and basename

struct NODE{
	char Name[64];           
	char Type[1];             /* D for directory F for file */
	struct NODE *childPtr, *siblingPtr, *parentPtr;
};

struct NODE *root, *cwd;                 /* root and CWD pointers */
char line[128];                   /* user input line */
char command[16], pathname[64];   /* user inputs */
char dname[64], bname[64];   /* string holders*/
int main(){                                                 //WORKS!!!
	// FILE *tempFile;
	int ID;
	initialize();
	cwd = root;
	// printf("%c\n", *cwd->Name);
	while(1){
		char *command;
		printf("root@simulation:~");
		pwd(cwd);
		printf("$ ");
		fgets(line, 128, stdin);
		command = strtok(line, " \n/");	// this breaks up the input into segments
		if(command != NULL){
			ID = findCommand(command);
		}
		else{
			ID = -1;
		}
		command = strtok(NULL, " \n");	// this breaks up the input into segments
		//       printf("\n%d_%s\n", ID, command);
		// printf("%s", cwd->childPtr->
		switch(ID){ 
			case -1 : printf("%s: command not found\n", line); break;
			case 0 : return 0;
			case 1 : mkdir(command);  break;
			case 2 : rmdir(command);  break;
			case 3 : cd(&cwd, command);break;
			case 4 : ls();            break;
			case 5 : pwd(cwd);	printf("\n");           break;
			case 6 : create(command);	      break;
			case 7 : rm(command);     break;
			case 8 : save(root, command);	 break;
			case 9 : reload(root, command);   break;
			case 10 : help(); break;
			//                   ...................

			// }
		}
	}
	return 0;
}
//big ass switchy thingy
int find_and_exec(const char * command_name, const char * parameters){
  int ret;
  if(command_name == NULL){
    return 0;
  }
  else if(strcmp(command_name,"pwd") == 0){
    return pwd();
  }
  else if(strcmp(command_name,"cd") == 0){
    return cd(parameters);
  }
  else if(strcmp(command_name,"echo") == 0){
    return echo(parameters);
  }
  else if(strcmp(command_name,"pushd") == 0){
    return pushd(parameters);
  }
  else if(strcmp(command_name,"popd") == 0){
    return popd();
  }
  else if(strcmp(command_name,"exit") == 0){
    exitc(parameters);
  }
  else if(strcmp(command_name,"set") == 0){
    printf("Did you mean export? If you are looking for windows try your walls\n");
    return 0;
  }
  else if(strcmp(command_name,"history") == 0){
    print_stack_lines(history);
    return 0;
  }
  else if(strcmp(command_name,"unsetenv") == 0){
    return unsetenv(parameters);
  }
  else {
    int pid = fork();
    if(pid == -1){return 1;}
    else if(pid == 0){
      if(parameters == NULL) {
        execlp(command_name,command_name,NULL);
      }
      else {
        execvp(command_name,split_spaces_cmd(command_name,parameters));
      }
    }
    else {
      wait(&ret);
      return ret;
    }
  }
  return 0;
}
示例#11
0
//
// 测试MD5计算
//
void YCTest::test_md5()
{
	const char* key = "ED0CBE1B3382F0FF";

	YCMd5 md5;

	std::string pwd("3852346538");
	md5.GenerateMD5((unsigned char*)pwd.c_str(), pwd.length());
	
	std::string md5code = md5.ToString();

	return;
}
示例#12
0
 void pwdgen_pin(void)
 {
   DomainSettings ds;
   ds.domainName = "Bank";
   ds.usedCharacters = "0123456789";
   ds.iterations = 1;
   ds.length = 4;
   ds.salt_base64 = QString("pepper").toUtf8().toBase64();
   Password pwd(ds);
   pwd.generate("reallysafe");
   QVERIFY(pwd.hexKey() == "55b5f5cdd9bf2845e339650b4f6e1398cf7fe9ceed087eb5f5bc059882723579fc8ec27443417cf33c9763bafac6277fbe991bf27dd0206e78f7d9dfd574167f");
   QVERIFY(pwd.key() == "7809");
 }
示例#13
0
 void pwdgen_simple_password_2(void)
 {
   DomainSettings ds;
   ds.domainName = "MyFavoriteDomain";
   ds.usedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ";
   ds.iterations = 8192;
   ds.length = 16;
   ds.salt_base64 = QString("pepper").toUtf8().toBase64();
   Password pwd(ds);
   pwd.generate("foobar");
   QVERIFY(pwd.hexKey() == "cb0ae7b2b7fc969770a9bfc1eef3a9afd02d2b28d6d8e9cb324f41a31392a0f800ea7e2e43e847537ceb863a16a869d5e4dd6822cf3be0206440eff97dc2001c");
   QVERIFY(pwd.key() == "wLUwoQvKzBaYXbme");
 }
示例#14
0
 void pwdgen_simple_1(void)
 {
   DomainSettings ds;
   ds.domainName = "ct.de";
   ds.usedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ0123456789#!\"§$%&/()[]{}=-_+*<>;:.";
   ds.iterations = 4096;
   ds.length = 10;
   ds.salt_base64 = QString("pepper").toUtf8().toBase64();
   Password pwd(ds);
   pwd.generate("test");
   QVERIFY(pwd.hexKey() == "f4d54b303b21ee3d8bff9c1eae6f66d90db58c0a5cc770eee322cc59d4dec65793bf8f5dec717fd1404bbfacf59befa68c4ad9168bfeaa6a9e28b326a76a82bb");
   QVERIFY(pwd.key() == "YBVUH=sN/3");
 }
示例#15
0
int cd(char *s)
{
    if(chdir(s) < 0) {
	fprintf(stderr,"cannot open %s\n",s);
	return -1;
    }
    pwd();
    ls();
    settlstrings(tl, filelist);
    muiChangeLabel(l4, directory);
    selectedfile = 0;
    return 0;
}
示例#16
0
/**
 * Quash entry point
 *
 * @param argc argument count from the command line
 * @param argv argument vector from the command line
 * @return program exit status
 */
int main(int argc, char** argv) { 
    command_t cmd; //< Command holder argument
      
    start();
    struct sigaction NULL_sa;
    struct sigaction sa;
    sigset_t mask_set;
    sigfillset(&mask_set);
    sigdelset(&mask_set,SIGINT);
    sigdelset(&mask_set,SIGTSTP);
    sa.sa_handler = catchChild;
    sigprocmask(SIG_SETMASK, &mask_set, NULL);
    //TODO: this is involved withe the error 10 problem. Removing it remedies the issue for now but breaks other things.
    sigaction(SIGCHLD, &sa,NULL);//child termination calls catchChild;

    setenv( "WKDIR", getenv("HOME"), 1 );

    puts("hOi! Welcome to Quash!");

    // Main execution loop
    while (is_running()) 
    {
        // NOTE: I would not recommend keeping anything inside the body of
        // this while loop. It is just an example.

        // The commands should be parsed, then executed.
        if( !get_command(&cmd, stdin) );
        else if (!strcmp(cmd.cmdstr, "q")||!strcmp(cmd.cmdstr, "exit")||!strcmp(cmd.cmdstr, "quit"))
            terminate(); // Exit Quash
        else if(!strcmp(cmd.execArgs[0], "set"))
            set(cmd);//set environment variables
        else if(!strcmp(cmd.execArgs[0], "echo"))
            echo(cmd);//echos environment variables
        else if(!strcmp(cmd.execArgs[0], "pwd"))
            pwd(cmd);//prints current working directory
        else if(!strcmp(cmd.execArgs[0], "cd"))
            cd(cmd);//changes the working directory
        else if(!strcmp(cmd.execArgs[0], "jobs"))
            jobs();//prints out a list of currently running jobs
        else if(!strcmp(cmd.execArgs[0], "kill"))
            killChild(cmd);//kills specified job
        else if (!strcmp(cmd.execArgs[0], "wait"))
            sleep(atoi(cmd.execArgs[1]));
        else if (strchr(cmd.cmdstr,'|')!= NULL)
            exec_pipes(cmd);//executes piped commands
        else 
            exec_cmd(cmd);//executes normal commands
    }

    return EXIT_SUCCESS;
}
示例#17
0
void
mdirs(char *fpath)
{
	DIR *dir;
	struct dirent *d;
	struct stat st;

	dir = opendir(fpath);
	if (!dir)
		return;

	if (chdir(fpath) < 0) {
		closedir(dir);
		return;
	}

	int dotonly = 0;

	if (stat("cur", &st) == 0 &&
	    S_ISDIR(st.st_mode) &&
	    stat("new", &st) == 0 &&
	    S_ISDIR(st.st_mode)) {
		pwd();
		dotonly = 1;   // Maildir++
	}

	while ((d = readdir(dir))) {
#if defined(DT_DIR) && defined(DT_UNKNOWN)
		if (d->d_type != DT_DIR && d->d_type != DT_UNKNOWN)
			continue;
#endif
		if (d->d_name[0] == '.' &&
		    d->d_name[1] == 0)
			continue;
		if (d->d_name[0] == '.' &&
		    d->d_name[1] == '.' &&
		    d->d_name[2] == 0)
			continue;

		if (dotonly && d->d_name[0] != '.')
			continue;

		mdirs(d->d_name);
	}

	if (chdir("..") < 0)
		exit(-1);

	closedir(dir);
}
示例#18
0
void GLESettings::writeAll()
{
	// Store the application settings
	settingStore->setValue("application/position", position());
	settingStore->setValue("application/size", size());
	settingStore->setValue("application/mainstate", mainWindowState());
	settingStore->setValue("application/drawingsize", drawingAreaSize());
	settingStore->setValue("application/storeSize", storeSize());
	settingStore->setValue("application/storeDirectory", storeDirectory());
	settingStore->setValue("application/saveOnPreview", saveOnPreview());
	settingStore->setValue("application/autoScaleOnOpen", autoScaleOnOpen());
	settingStore->setValue("application/libGSLocation", getLibGSLocation());
	settingStore->setValue("application/editorLocation", editorLocation());
	settingStore->setValue("application/resolution", dpi());
	settingStore->setValue("application/monitorOpenFile", monitorOpenFile());
	settingStore->setValue("application/monitorAutoReload", monitorAutoReloadFile());
	settingStore->setValue("application/askAboutKeepingObjects", askAboutObjects());
	settingStore->setValue("application/splitterSizes", splitterPosition());
	settingStore->setValue("application/consoleAutoShowSize", getConsoleWindowAutoShowSize());
	settingStore->setValue("application/emulateGLEVersion", getEmulateGLEVersion());
	settingStore->setValue("application/exportFormat", getExportFormat());
	settingStore->setValue("application/exportPageSize", getExportPageSize());
	settingStore->setValue("application/previewPageSize", getPreviewPageSize());
	settingStore->setValue("application/openExportedFigure", isOpenExportedFigure());
	settingStore->setValue("application/exportGrayScale", isExportGrayScale());
	settingStore->setValue("application/exportTransparent", isExportTransparent());
	settingStore->setValue("application/exportBitmapResolution", getExportBitmapResolution());
	settingStore->setValue("application/exportVectorResolution", getExportVectorResolution());
	settingStore->setValue("application/renderUsingCairo", isRenderUsingCairo());

	if (storeDirectory())
		settingStore->setValue("application/workingDirectory", pwd());

	// Store the server settings
	settingStore->setValue("server/portNumber", port());
	settingStore->setValue("server/autoStart", autoStartServer());

	// Store the drawing settings
	settingStore->setValue("drawing/gridX", grid().x());
	settingStore->setValue("drawing/gridY", grid().y());
	settingStore->setValue("drawing/equalGrid", equalGrid());

	settingStore->setValue("drawing/polarSnapStartAngle", polarSnapStartAngle());
	settingStore->setValue("drawing/polarSnapIncAngle", polarSnapIncAngle());
	settingStore->setValue("drawing/osnapOnStart", osnapOnStart());
	settingStore->setValue("drawing/orthoSnapOnStart", orthoSnapOnStart());
	settingStore->setValue("drawing/polarSnapOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/polarTrackOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/gridSnapOnStart", gridSnapOnStart());
}
示例#19
0
文件: lab2v11.c 项目: zeke225/cs360
reload(struct NODE *inputCWD, char *inputFile){             //Need to finish
	// First we need to clear the existing directory
	FILE *infile;
	char *tempName, tempDirName[128];
	if (inputFile == NULL){
		printf("ERROR: No input file name.\n");
		return 0;
	}
	else{
		cwd = root;
		if(root->childPtr){
			recursiveDelete(root->childPtr);
			root->childPtr = NULL;
		}
		infile = fopen(inputFile, "r");
		if(fgets(line, sizeof(line), infile) != NULL && line[0] == '/'){
			//          printf("read '%s'",line);

			while (fgets(line, sizeof(line), infile) != NULL){
				//pwd(cwd);
				tempName = strtok(line, "\n");
				printf("read '%s' == '%s'\n",line, tempName);
				if(tempName && tempName[0] == '~'){
					tempName = strtok(line, "~\n");
					while(tempName){
						printf("create '%s'\n",tempName);
						reloadCreate(tempName);
						tempName = strtok(NULL, "~");
					}
				}
				if(tempName && tempName[0] == '/'){
					printf("mkdirs: '%s'\n",tempName);
					// cd(&cwd, "/");
					strcpy(tempDirName, tempName);
					printf("cd: '%s'\n", dirname(tempDirName));
					printf("mkdirs: '%s'\n",tempName);
					cd(&cwd, tempDirName);
					reloadMkdir(basename(tempName));
					cd(&cwd, basename(tempName));
					printf("Now in:");
					pwd(cwd);
					printf("\n");
				}
			}
		}
	}
	cd(&cwd, "/");
	return 1;
}
示例#20
0
 void pwdgen_binary_salt_and_password(void)
 {
   DomainSettings ds;
   ds.domainName = "Foo";
   ds.usedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ";
   ds.iterations = 1024;
   ds.length = 32;
   static uchar salt[256] = { 219, 234, 34, 57, 151, 182, 99, 40, 180, 243, 133, 33, 191, 250, 4, 226, 107, 19, 132, 160, 29, 73, 184, 194, 38, 109, 104, 126, 43, 108, 215, 45, 253, 44, 204, 83, 229, 220, 146, 136, 110, 0, 232, 25, 212, 23, 205, 157, 91, 179, 200, 248, 102, 17, 101, 164, 113, 130, 27, 141, 79, 177, 47, 123, 36, 210, 183, 65, 64, 140, 72, 134, 207, 100, 233, 35, 211, 131, 75, 186, 70, 156, 105, 21, 66, 216, 241, 169, 15, 144, 111, 122, 181, 135, 118, 39, 228, 37, 188, 26, 14, 147, 49, 95, 2, 244, 119, 154, 171, 218, 77, 187, 3, 127, 217, 22, 129, 69, 185, 206, 152, 5, 115, 106, 6, 96, 227, 255, 125, 155, 18, 240, 238, 55, 32, 128, 84, 89, 252, 172, 28, 67, 225, 214, 121, 237, 93, 148, 59, 139, 87, 97, 158, 199, 98, 94, 68, 247, 41, 86, 13, 142, 196, 197, 195, 82, 78, 116, 60, 209, 7, 9, 174, 189, 150, 221, 175, 224, 213, 145, 92, 231, 170, 208, 81, 254, 76, 246, 198, 71, 203, 192, 124, 167, 137, 222, 31, 249, 58, 190, 11, 20, 10, 168, 46, 235, 88, 245, 114, 74, 176, 163, 1, 223, 8, 193, 30, 54, 166, 52, 24, 85, 90, 162, 117, 236, 120, 178, 143, 63, 159, 173, 161, 61, 48, 42, 103, 80, 251, 56, 202, 53, 153, 201, 51, 230, 242, 112, 149, 239, 138, 165, 16, 62, 12, 50 };
   static uchar password[256] = { 136, 152, 37, 207, 212, 209, 100, 16, 137, 118, 4, 205, 115, 26, 21, 19, 99, 30, 156, 31, 102, 35, 130, 114, 22, 191, 32, 248, 155, 60, 120, 44, 167, 107, 197, 123, 27, 138, 171, 133, 186, 69, 122, 58, 70, 147, 51, 62, 164, 236, 61, 81, 72, 3, 218, 11, 134, 24, 230, 227, 54, 43, 124, 168, 113, 84, 144, 217, 9, 184, 163, 64, 195, 34, 173, 5, 8, 192, 91, 63, 40, 12, 6, 140, 74, 125, 52, 196, 110, 46, 229, 198, 220, 247, 131, 202, 177, 216, 246, 106, 161, 219, 146, 41, 226, 154, 28, 148, 117, 238, 18, 92, 135, 231, 180, 75, 211, 141, 94, 67, 185, 160, 23, 105, 187, 47, 53, 253, 95, 232, 242, 169, 240, 181, 172, 139, 116, 1, 179, 178, 80, 143, 20, 7, 243, 101, 252, 176, 228, 48, 224, 0, 206, 50, 249, 104, 89, 88, 199, 78, 17, 33, 200, 194, 132, 83, 97, 57, 56, 222, 183, 214, 68, 250, 73, 108, 237, 71, 29, 221, 251, 98, 204, 45, 245, 121, 255, 193, 182, 79, 14, 254, 190, 15, 153, 127, 215, 119, 111, 2, 225, 90, 223, 233, 213, 36, 151, 59, 210, 49, 159, 241, 10, 86, 188, 162, 109, 65, 42, 235, 103, 128, 234, 157, 189, 77, 201, 25, 82, 166, 203, 239, 96, 38, 244, 175, 39, 142, 112, 170, 55, 93, 165, 76, 13, 208, 150, 126, 85, 66, 158, 87, 145, 129, 174, 149 };
   ds.salt_base64 = QByteArray(reinterpret_cast<char*>(salt), 256).toBase64();
   Password pwd(ds);
   pwd.generate(SecureByteArray(reinterpret_cast<char*>(password), 256));
   QVERIFY(pwd.hexKey() == "e217c512b32d61f94bccad89b9c79012d073f4c0960854803a6115aa928f5b823d3bcd167872d4df102450f4dc26d82c6fa6666f749f82b2ec12593edb6ba2b0");
   QVERIFY(pwd.key() == "XQCjlTFKFWBAsmgYgzTwJdbFPjCyykCl");
 }
示例#21
0
int check_built_in(char **command, int num_args, char **path_list, int *path_num) {
	
	if(cd(command, num_args) == 0) {
		return 0;
	}
	else if(pwd(command) == 0) {
		return 0;
	}
	else if(path(command, num_args, path_list, path_num) == 0) {
		return 0;
	}
	else {
		return 1;
	}
}
示例#22
0
文件: tty.c 项目: Distrotech/joe
static unsigned char *getpty(int *ptyfd)
{
	int x, fd;
	unsigned char *orgpwd = pwd();
	static unsigned char **ptys = NULL;
	static unsigned char *ttydir;
	static unsigned char *ptydir;
	static unsigned char ttyname[32];

	if (!ptys) {
		ttydir = USTR "/dev/pty/";
		ptydir = USTR "/dev/ptym/";	/* HPUX systems */
		if (chpwd(ptydir) || !(ptys = rexpnd(USTR "pty*")))
			if (!ptys) {
				ttydir = ptydir = USTR "/dev/";	/* Everyone else */
				if (!chpwd(ptydir))
					ptys = rexpnd(USTR "pty*");
			}
	}
	chpwd(orgpwd);

	if (ptys)
		for (fd = 0; ptys[fd]; ++fd) {
			zcpy(ttyname, ptydir);
			zcat(ttyname, ptys[fd]);
			if ((*ptyfd = open((char *)ttyname, O_RDWR)) >= 0) {
				ptys[fd][0] = 't';
				zcpy(ttyname, ttydir);
				zcat(ttyname, ptys[fd]);
				ptys[fd][0] = 'p';
				x = open((char *)ttyname, O_RDWR);
				if (x >= 0) {
					close(x);
					close(*ptyfd);
					zcpy(ttyname, ptydir);
					zcat(ttyname, ptys[fd]);
					*ptyfd = open((char *)ttyname, O_RDWR);
					ptys[fd][0] = 't';
					zcpy(ttyname, ttydir);
					zcat(ttyname, ptys[fd]);
					ptys[fd][0] = 'p';
					return ttyname;
				} else
					close(*ptyfd);
			}
		}
	return NULL;
}
示例#23
0
//______________________________________________________________________________
void bexec2(char *macro)
{
   printf("in bexec dir=%s\n",pwd());
   if (gROOT->IsBatch()) printf("Processing benchmark: %s\n",macro);
   TPaveText *summary = (TPaveText*)bench->GetPrimitive("TPave");
   TText *tmacro = summary->GetLineWith(macro);
   if (tmacro) tmacro->SetTextColor(4);
   bench->Modified(); bench->Update();

   gROOT->Macro(macro);

   TPaveText *summary2 = (TPaveText*)bench->GetPrimitive("TPave");
   TText *tmacro2 = summary2->GetLineWith(macro);
   if (tmacro2) tmacro2->SetTextColor(2);
   bench->Modified(); bench->Update();
}
示例#24
0
文件: ui.cpp 项目: CecilHarvey/lord
int CUIManager::NetGameMenu()
{
   CBox box(100, 100, 440, 280, 200, 50, 170);
   CTextBox playerName(180, 120, 20, cfg.Get("GAME", "PlayerName", "Player"));
   gpGeneral->DrawText(msg("menu_playername"), 110, 120, 255, 250, 50);
   CTextBox pwd(180, 150, 20, cfg.Get("GAME", "ServerPwd", ""));
   gpGeneral->DrawText(msg("menu_password"), 110, 150, 255, 250, 50);
   CTextBox hostName(180, 180, 20, cfg.Get("GAME", "HostName", ""));
   gpGeneral->DrawText(msg("menu_hostaddr"), 110, 180, 255, 250, 50);

   CButton btnServer(1, 110, 350, 100, 20, 50, 220, 200);
   gpGeneral->DrawText(msg("menu_server"), 160 - strlen(msg("menu_server")) * 4, 352, 255, 250, 50);
   CButton btnClient(2, 220, 350, 100, 20, 50, 220, 200);
   gpGeneral->DrawText(msg("menu_client"), 270 - strlen(msg("menu_client")) * 4, 352, 255, 250, 50);
   CButton btnCancel(3, 330, 350, 100, 20, 50, 220, 200);
   gpGeneral->DrawText(msg("menu_cancel"), 380 - strlen(msg("menu_cancel")) * 4, 352, 255, 250, 50);

   while (1) {
      int key = gpGeneral->ReadKey() - SDLK_LAST;
      if (key == 1) {
         // SERVER button pressed
         if (strlen(playerName.Text()) > 0) {
            cfg.Set("GAME", "PlayerName", playerName.Text());
         }
         cfg.Set("GAME", "ServerPwd", pwd.Text());
         gpGeneral->DrawText(msg("connecting"), 0, 440, 255, 255, 0);
         return 1;
      } else if (key == 2) {
         // CLIENT button pressed
         if (strlen(hostName.Text()) <= 0) {
            continue;
         }
         if (strlen(playerName.Text()) > 0) {
            cfg.Set("GAME", "PlayerName", playerName.Text());
         }
         cfg.Set("GAME", "HostName", hostName.Text());
         cfg.Set("GAME", "ServerPwd", pwd.Text());
         gpGeneral->DrawText(msg("connecting"), 0, 440, 255, 255, 0);
         return 2;
      } else if (key == 3) {
         // Cancel button pressed
         return 0; // do nothing
      }
   }
   return 0;
}
示例#25
0
void MirallConfigFile::writeOwncloudConfig( const QString& connection,
                                            const QString& url,
                                            const QString& user,
                                            const QString& passwd,
                                            bool https, bool skipPwd )
{
    const QString file = configFile();
    qDebug() << "*** writing mirall config to " << file << " Skippwd: " << skipPwd;
    QString pwd( passwd );

    QSettings settings( file, QSettings::IniFormat);
    settings.setIniCodec( "UTF-8" );
    QString cloudsUrl( url );

    if( !cloudsUrl.startsWith( QLatin1String("http")) ) {
        if (https)
            cloudsUrl.prepend(QLatin1String("https://"));
        else
            cloudsUrl.prepend(QLatin1String("http://"));
    }

    settings.beginGroup( connection );
    settings.setValue( QLatin1String("url"), cloudsUrl );
    settings.setValue( QLatin1String("user"), user );
    if( skipPwd ) {
        pwd.clear();
    }

#ifdef WITH_QTKEYCHAIN
    // Password is stored to QtKeyChain now by default in CredentialStore
    // The CredentialStore calls clearPasswordFromConfig after the creds
    // were successfully wiritten to delete the passwd entry from config.
    qDebug() << "Going to delete the password from settings file.";
#else
    if( !skipPwd )
        writePassword( passwd );
#endif
    settings.setValue( QLatin1String("nostoredpassword"), QVariant(skipPwd) );
    settings.sync();
    // check the perms, only read-write for the owner.
    QFile::setPermissions( file, QFile::ReadOwner|QFile::WriteOwner );

    // Store credentials temporar until the config is finalized.
    CredentialStore::instance()->setCredentials( cloudsUrl, user, passwd );

}
示例#26
0
bool MirallConfigFile::writePassword( const QString& passwd, const QString& connection )
{
    const QString file = configFile();
    QString pwd( passwd );
    QString con( defaultConnection() );
    if( !connection.isEmpty() )
        con = connection;

    QSettings settings( file, QSettings::IniFormat);
    settings.setIniCodec( "UTF-8" );

    // store password into settings file.
    settings.beginGroup( con );
    QByteArray pwdba = pwd.toUtf8();
    settings.setValue( QLatin1String("passwd"), QVariant(pwdba.toBase64()) );
    settings.sync();
}
示例#27
0
QString jsBridge::decrypt(QString data, QString hint)
{
    bool error = false;
    while (true) {
        PasswordDialog pwd(qApp->activeWindow(), false);
        pwd.setHint(hint);
        pwd.setError(error);
        if (pwd.exec() == QDialog::Accepted){

            RC2_KEY key;
            QByteArray b = QByteArray::fromBase64(data.toLatin1());

            QByteArray r = QCryptographicHash::hash(pwd.getPassword().toUtf8(), QCryptographicHash::Md5);
            RC2_set_key(&key, r.size(), (const unsigned char*)r.data(), 64);

            unsigned char * buf2 = new unsigned char[8];

            QByteArray result;

            while (b.size()>0) {
                QByteArray x = b.left(8);
                RC2_ecb_encrypt((const unsigned char*)x.data(),buf2,&key,RC2_DECRYPT);
                result += QByteArray((const char *)buf2, x.size());
                b.remove(0, 8);
            }

            QString crc1 = QString::fromUtf8(result.left(4));
            result.remove(0, 4);

            ulong crc = crc32(0, NULL, 0);
            crc = crc32(crc, (const Bytef *)result.data(), result.size());
            QString crc2 = QString(QByteArray::number(~(uint)crc, 16).left(4));

            if (QString::compare(crc1, crc2, Qt::CaseInsensitive) != 0){
                error = true;
                continue;
            }

            return result;
        }
        else
            return QString();
    }
    return QString();
}
示例#28
0
QVariantMap jsBridge::encrypt(QString data)
{
    QVariantMap passJson;
    passJson["ok"] = false;

    PasswordDialog pwd(qApp->activeWindow(), true);
    if (pwd.exec() != QDialog::Accepted)
        return passJson;

    passJson["hint"] = pwd.getHint();

    RC2_KEY key;
    QByteArray r = QCryptographicHash::hash(pwd.getPassword().toUtf8(), QCryptographicHash::Md5);
    RC2_set_key(&key, r.size(), (const unsigned char*)r.data(), 64);

    QByteArray b = data.toUtf8();

    char null_ = 0;
    while (((b.size() + 4) % 8) != 0)
        b.append(null_);

    ulong crc = crc32(0, NULL, 0);
    crc = crc32(crc, (const Bytef *)b.data(), b.size());
    QString crc2 = QString(QByteArray::number(~(uint)crc, 16).left(4)).toUpper();

    b = crc2.toLatin1() + b;

    unsigned char * buf2 = new unsigned char[8];

    QByteArray result;

    while (b.size()>0) {
        QByteArray x = b.left(8);
        RC2_ecb_encrypt((const unsigned char*)x.data(),buf2,&key,RC2_ENCRYPT);
        result += QByteArray((const char *)buf2, 8);
        b.remove(0, 8);
    }

    if (!result.isEmpty()){
        passJson["data"] = QString::fromLatin1(result.toBase64());
        passJson["ok"] = true;
    }

    return passJson;
}
示例#29
0
文件: run.c 项目: DGBlueWolf/OSCSC456
int Run( int cmd_num , int args, char** arg_list )
{
  switch( cmd_num )
  {
    case CMDNM:
      if( args != 2 )
      {
        fprintf(stderr, "cmdnm requires 1 argument: <process_id>\n" );
        return -1;
      }
      return cmdnm( arg_list[1] );
    case SIGNAL:
      if( args != 3 )
      {
        fprintf( stderr,
                "signal requires 2 arguments: <signal_num> <process_id>\n" );
        return -1;
      }
      return send_signal( arg_list[1] , arg_list[2] );
    case SYSTAT:
      return systat();
    case EXIT:
      return 2;
    case CD:
      if( args != 2 )
      {
        fprintf(stderr,
               "cd requires 1 argument: <relative path> or <absolute_path>\n" );
        return -1;
      }
      return cd( arg_list[1] );
    case PWD:
      return pwd();
    case HB:
      if( args != 4 )
      {
        fprintf( stderr, "hb requires 3 arguments: <tinc> <tend> <tval>\n" );
        return -1;
      }
      return hb( atoi(arg_list[1]) , atoi(arg_list[2]) , arg_list[3] );
  }
  return 0;
}
示例#30
0
文件: terminal.c 项目: thigley/THOS
int runCommand(){
	int i = 0;
	int argc = splitString(textBuffer, ' ');
	for(i =0;i<argc;i++){argv[i]=stringArray[i];}
	
	if(k_strcmp(argv[0], "")==0){}
	else if(k_strcmp(argv[0], "clear")==0){ clearScreen(); typeOffset = 0;}
	else if(k_strcmp(argv[0], "history")==0){ printHistory();}
	else if(k_strcmp(argv[0], "pong")==0){ pong();}
	else if(k_strcmp(argv[0], "help")==0){ listCommands();}
	else if(k_strcmp(argv[0], "welcome")==0){ welcome();}
	else if(k_strcmp(argv[0], "splash")==0){ splash();}
	else if(k_strcmp(argv[0], "ls")==0){ ls(argc, argv); }
	else if(k_strcmp(argv[0], "cat")==0){ cat(argc, argv); }
	else if(k_strcmp(argv[0], "rm")==0){ rm(argc, argv); }
	else if(k_strcmp(argv[0], "chmod")==0){ chmod(argc, argv); }
	else if(k_strcmp(argv[0], "te")==0){ te(argc, argv); }
	else if(k_strcmp(argv[0], "cp")==0){ cp(argc, argv); }
	else if(k_strcmp(argv[0], "diff")==0){ diff(argc, argv); }
	else if(k_strcmp(argv[0], "wc")==0){ wc(argc, argv); }
	else if(k_strcmp(argv[0], "su")==0){ su(argc, argv); }
	else if(k_strcmp(argv[0], "chown")==0){ chown(argc, argv); }
	else if(k_strcmp(argv[0], "echo")==0){ echo(argc, argv); }
	else if(k_strcmp(argv[0], "adduser")==0){ adduser(argc, argv); }
	else if(k_strcmp(argv[0], "deluser")==0){ deluser(argc, argv); }
	else if(k_strcmp(argv[0], "listus")==0){ listus(); }
	else if(k_strcmp(argv[0], "passwd")==0){ passwd(argc, argv); }

	else if(k_strcmp(argv[0], "mkdir")==0){ mkdir(argc, argv); }
	else if(k_strcmp(argv[0], "rmdir")==0){ rmdir(argc, argv); }
	else if(k_strcmp(argv[0], "cd")==0){ cd(argc, argv); }
	else if(k_strcmp(argv[0], "pwd")==0){ pwd(argc, argv); }
	else if(k_strcmp(argv[0], "mv")==0){ mv(argc, argv); }

	// else check files
	else {
		printToConsole("Error: Unknown command '");
		printToConsole(argv[0]);
		printToConsole("'\n");
	}

	return 0;
}