/************************************************************************* * UrBackup - Client/Server backup system * Copyright (C) 2011-2016 Martin Raiber * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . **************************************************************************/ #include "tokens.h" #include "../Interface/Server.h" #include "database.h" #include "../stringtools.h" #ifndef _WIN32 #include #include #endif namespace tokens { bool write_tokens() { IDatabase* db = Server->getDatabase(Server->getThreadID(), URBACKUPDB_CLIENT); ClientDAO dao(db); std::string hostname = get_hostname(); DBScopedWriteTransaction write_transaction(db); bool has_new_token=false; std::vector users = get_local_users(); os_create_dir(tokens_path); #ifndef _WIN32 chmod(tokens_path, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); #endif std::vector files = getFilesWin(tokens_path, nullptr, false, false); for(size_t i=0;i user_groups = get_user_groups(users[i]); for (size_t j=0;j