| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CRYPTOHOME_PLATFORM_H_ | 5 #ifndef CRYPTOHOME_PLATFORM_H_ |
| 6 #define CRYPTOHOME_PLATFORM_H_ | 6 #define CRYPTOHOME_PLATFORM_H_ |
| 7 | 7 |
| 8 #include <base/basictypes.h> | 8 #include <base/basictypes.h> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 virtual bool TerminatePidsForUser(const uid_t uid, bool hard); | 123 virtual bool TerminatePidsForUser(const uid_t uid, bool hard); |
| 124 | 124 |
| 125 // Returns a vector of PIDs whose Real, Effective, Saved, or File UID is equal | 125 // Returns a vector of PIDs whose Real, Effective, Saved, or File UID is equal |
| 126 // to that requested | 126 // to that requested |
| 127 // | 127 // |
| 128 // Parameters | 128 // Parameters |
| 129 // uid - the user ID to search for | 129 // uid - the user ID to search for |
| 130 // pids (OUT) - the list of PIDs | 130 // pids (OUT) - the list of PIDs |
| 131 void GetPidsForUser(uid_t uid, std::vector<pid_t>* pids); | 131 void GetPidsForUser(uid_t uid, std::vector<pid_t>* pids); |
| 132 | 132 |
| 133 // Calls the platform chown() function on the given path. |
| 134 // |
| 135 // The path may be a directory or a file. |
| 136 // |
| 137 // Parameters |
| 138 // path - The path to set ownership on |
| 139 // user_id - The user_id to assign ownership to |
| 140 // group_id - The group_id to assign ownership to |
| 141 virtual bool SetOwnership(const std::string& directory, uid_t user_id, |
| 142 gid_t group_id); |
| 143 |
| 133 // Calls the platform chown() function recursively on the directory | 144 // Calls the platform chown() function recursively on the directory |
| 134 // | 145 // |
| 135 // Parameters | 146 // Parameters |
| 136 // directory - The directory to set ownership on | 147 // directory - The directory to set ownership on |
| 137 // user_id - The user_id to assign ownership to | 148 // user_id - The user_id to assign ownership to |
| 138 // group_id - The group_id to assign ownership to | 149 // group_id - The group_id to assign ownership to |
| 139 virtual bool SetOwnership(const std::string& directory, uid_t user_id, | 150 virtual bool SetOwnershipRecursive(const std::string& directory, |
| 140 gid_t group_id); | 151 uid_t user_id, |
| 152 gid_t group_id); |
| 141 | 153 |
| 142 // Sets the current umask, returning the old mask | 154 // Sets the current umask, returning the old mask |
| 143 // | 155 // |
| 144 // Parameters | 156 // Parameters |
| 145 // new_mask - The mask to set | 157 // new_mask - The mask to set |
| 146 virtual int SetMask(int new_mask); | 158 virtual int SetMask(int new_mask); |
| 147 | 159 |
| 148 // Returns the user and group ids for a user | 160 // Returns the user and group ids for a user |
| 149 // | 161 // |
| 150 // Parameters | 162 // Parameters |
| 151 // user - The username to query for | 163 // user - The username to query for |
| 152 // user_id (OUT) - The user ID on success | 164 // user_id (OUT) - The user ID on success |
| 153 // group_id (OUT) - The group ID on success | 165 // group_id (OUT) - The group ID on success |
| 154 virtual bool GetUserId(const std::string& user, uid_t* user_id, | 166 virtual bool GetUserId(const std::string& user, uid_t* user_id, |
| 155 gid_t* group_id); | 167 gid_t* group_id); |
| 156 | 168 |
| 169 // Returns the group id for a group |
| 170 // |
| 171 // Parameters |
| 172 // group - The group name to query for |
| 173 // group_id (OUT) - The group ID on success |
| 174 virtual bool GetGroupId(const std::string& group, gid_t* group_id); |
| 175 |
| 157 // Return the available disk space in bytes on the volume containing |path|, | 176 // Return the available disk space in bytes on the volume containing |path|, |
| 158 // or -1 on failure. | 177 // or -1 on failure. |
| 159 // Code duplicated from Chrome's base::SysInfo::AmountOfFreeDiskSpace(). | 178 // Code duplicated from Chrome's base::SysInfo::AmountOfFreeDiskSpace(). |
| 160 // | 179 // |
| 161 // Parameters | 180 // Parameters |
| 162 // path - the pathname of any file within the mounted file system | 181 // path - the pathname of any file within the mounted file system |
| 163 virtual int64 AmountOfFreeDiskSpace(const std::string& path) const; | 182 virtual int64 AmountOfFreeDiskSpace(const std::string& path) const; |
| 164 | 183 |
| 165 // Clears the user keyring | 184 // Clears the user keyring |
| 166 static void ClearUserKeyring(); | 185 static void ClearUserKeyring(); |
| 167 | 186 |
| 187 // Creates a symbolic link from one path to the other |
| 188 // |
| 189 // Parameters |
| 190 // from - source path that the symlink points to |
| 191 // to - symlink to create which points to the source path |
| 192 virtual bool Symlink(const std::string& from, const std::string& to); |
| 193 |
| 194 // Executes a command with the specified arguments and waits for it to finish |
| 195 // |
| 196 // Parameters |
| 197 // command - string containing the filename of the binary to execute |
| 198 // args - list of arguments to pass to the run the command with |
| 199 // uid - effective user id to run the command with |
| 200 // gid - effective group id to run the command with |
| 201 bool Exec(const std::string& command, |
| 202 const std::vector<std::string>& args, |
| 203 uid_t uid, |
| 204 gid_t gid); |
| 205 |
| 168 // Overrides the default mount options | 206 // Overrides the default mount options |
| 169 void set_mount_options(int value) { | 207 void set_mount_options(int value) { |
| 170 mount_options_ = value; | 208 mount_options_ = value; |
| 171 } | 209 } |
| 172 | 210 |
| 173 // Overrides the default mtab file | 211 // Overrides the default mtab file |
| 174 void set_mtab_file(const std::string& value) { | 212 void set_mtab_file(const std::string& value) { |
| 175 mtab_file_ = value; | 213 mtab_file_ = value; |
| 176 } | 214 } |
| 177 | 215 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 private: | 291 private: |
| 254 std::vector<std::string> cmd_line_; | 292 std::vector<std::string> cmd_line_; |
| 255 std::set<std::string> open_files_; | 293 std::set<std::string> open_files_; |
| 256 std::string cwd_; | 294 std::string cwd_; |
| 257 int process_id_; | 295 int process_id_; |
| 258 }; | 296 }; |
| 259 | 297 |
| 260 } // namespace cryptohome | 298 } // namespace cryptohome |
| 261 | 299 |
| 262 #endif // CRYPTOHOME_PLATFORM_H_ | 300 #endif // CRYPTOHOME_PLATFORM_H_ |
| OLD | NEW |