1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2009-2010 Red Hat, Inc. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 #ifndef __USER__ 21 #define __USER__ 22 23 #include <sys/types.h> 24 #include <pwd.h> 25 #ifdef HAVE_SHADOW_H 26 #include <shadow.h> 27 #endif 28 29 #include <glib.h> 30 #include <gio/gio.h> 31 32 #include "types.h" 33 34 G_BEGIN_DECLS 35 36 #define TYPE_USER (user_get_type ()) 37 #define USER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_USER, User)) 38 #define IS_USER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_USER)) 39 40 typedef enum { 41 ACCOUNT_TYPE_STANDARD, 42 ACCOUNT_TYPE_ADMINISTRATOR, 43 #define ACCOUNT_TYPE_LAST ACCOUNT_TYPE_ADMINISTRATOR 44 } AccountType; 45 46 typedef enum { 47 PASSWORD_MODE_REGULAR, 48 PASSWORD_MODE_SET_AT_LOGIN, 49 PASSWORD_MODE_NONE, 50 #define PASSWORD_MODE_LAST PASSWORD_MODE_NONE 51 } PasswordMode; 52 53 /* local methods */ 54 55 GType user_get_type (void) G_GNUC_CONST; 56 User * user_new (Daemon *daemon, 57 uid_t uid); 58 59 #ifdef HAVE_SHADOW_H 60 void user_update_from_pwent (User *user, 61 struct passwd *pwent, 62 struct spwd *spent); 63 #else 64 void user_update_from_pwent (User *user, 65 struct passwd *pwent); 66 #endif 67 void user_update_from_keyfile (User *user, 68 GKeyFile *keyfile); 69 void user_update_local_account_property (User *user, 70 gboolean local); 71 void user_update_system_account_property (User *user, 72 gboolean system); 73 gboolean user_get_cached (User *user); 74 void user_set_cached (User *user, 75 gboolean cached); 76 void user_set_saved (User *user, 77 gboolean saved); 78 79 void user_register (User *user); 80 void user_unregister (User *user); 81 void user_changed (User *user); 82 83 void user_save (User *user); 84 85 const gchar * user_get_user_name (User *user); 86 gboolean user_get_system_account (User *user); 87 gboolean user_get_local_account (User *user); 88 const gchar * user_get_object_path (User *user); 89 uid_t user_get_uid (User *user); 90 const gchar * user_get_shell (User *user); 91 92 G_END_DECLS 93 94 #endif 95