예제 #1
0
파일: server.go 프로젝트: CPSSD/MDFS
func createPerm(filepath string, owner uint64, groups []uint64, permissions []bool) error {

	var tmpPerm utils.Perm

	tmpPerm.Owner = owner
	tmpPerm.Groups = groups
	tmpPerm.Permissions = permissions

	return utils.StructToFile(tmpPerm, filepath+"/.perm")
}
예제 #2
0
파일: server.go 프로젝트: CPSSD/MDFS
func createFile(fileout, hash, unid string, protected bool, owner uint64, groups []uint64, permissions []bool) error {

	var tmpFileDesc utils.FileDesc

	tmpFileDesc.Hash = hash
	tmpFileDesc.Stnode = unid
	tmpFileDesc.Protected = protected
	tmpFileDesc.Owner = owner
	tmpFileDesc.Groups = groups
	tmpFileDesc.Permissions = permissions

	return utils.StructToFile(tmpFileDesc, fileout)
}
예제 #3
0
파일: mdfs-client.go 프로젝트: CPSSD/MDFS
func setup(r *bufio.Reader, w *bufio.Writer, thisUser *utils.User) (err error) {

	fmt.Println("Please enter your username:\n")
	fmt.Print("Username: "******"/.mdfs/client/" + uname + "/.user_data")
	if exists != nil { // not exist

		// Make sure the local user dir exists
		err := os.MkdirAll(utils.GetUserHome()+"/.mdfs/client/"+uname+"/files", 0777)
		if err != nil {
			return err
		}

		// notify mdservice that this is a new user (SENDCODE 10)
		err = w.WriteByte(10) //
		if err != nil {
			return err
		}
		w.Flush()

		// local user setup
		utils.GenUserKeys(utils.GetUserHome() + "/.mdfs/client/" + uname + "/.private_key")

		err = utils.FileToStruct(utils.GetUserHome()+"/.mdfs/client/"+uname+"/.private_key", &thisUser.Privkey)
		if err != nil {
			return err
		}
		thisUser.Pubkey = &thisUser.Privkey.PublicKey

		// send username and keys
		w.WriteString(uname + "\n")
		w.Write([]byte(thisUser.Pubkey.N.String() + "\n"))
		w.Write([]byte(strconv.Itoa(thisUser.Pubkey.E) + "\n"))
		w.Flush()

		uuid, _ := r.ReadString('\n')
		thisUser.Uuid, err = strconv.ParseUint(strings.TrimSpace(uuid), 10, 64)
		if err != nil {
			return err
		}

		err = utils.StructToFile(*thisUser, utils.GetUserHome()+"/.mdfs/client/"+uname+"/.user_data")
		if err != nil {
			return err
		}

		//NOTE: NOT COMPLETE

	} else {

		err = utils.FileToStruct(utils.GetUserHome()+"/.mdfs/client/"+uname+"/.user_data", &thisUser)
		w.WriteByte(9)
		w.Flush()

	}

	return err

	// if none exist, will send a code to mdserv to notify as new user,
	// and get a uuid, create userkeys, send pubkey to mdserv

}