home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / UsersConfig.pm < prev   
Encoding:
Perl POD Document  |  2011-09-23  |  3.0 KB  |  100 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # DBus object for the Users list
  4. #
  5. # Copyright (C) 2005 Carlos Garnacho
  6. #
  7. # Authors: Carlos Garnacho Parro  <carlosg@gnome.org>,
  8. #          Milan Bouchet-Valat <nalimilan@club.fr>.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU Library General Public License as published
  12. # by the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. # GNU Library General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Library General Public License
  21. # along with this program; if not, write to the Free Software
  22. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  23.  
  24. package UsersConfig;
  25.  
  26. use base qw(StbObject);
  27. use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX);
  28. use UserConfig;
  29. use Users::Users;
  30. use Users::Shells;
  31.  
  32. my $OBJECT_NAME = "UsersConfig2";
  33. my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME";
  34.  
  35. # settings: list of shells, umin, umax, home prefix, default shell, default group, encrypted home support
  36. # only configuration settings are set via UsersConfig
  37. my $set_format = [ [ "array", "string" ], "uint32", "uint32", "string", "string", "uint32", "bool" ];
  38. # array of users plus configuration settings
  39. my $get_format = [[ "array", $UserConfig::USER_FORMAT ], [ "array", "string" ], "uint32", "uint32", "string", "string", "uint32", "bool" ];
  40.  
  41.  
  42. sub new
  43. {
  44.   my $class = shift;
  45.   my $self  = $class->SUPER::new ($OBJECT_PATH, $OBJECT_NAME);
  46.  
  47.   bless $self, $class;
  48.  
  49.   return $self;
  50. }
  51.  
  52. dbus_method ("get", [], $get_format);
  53. dbus_method ("set", $set_format, []);
  54.  
  55. sub get
  56. {
  57.   my ($self) = @_;
  58.   my $logindefs, $users, $shells, $ecryptfs_support;
  59.   $self->SUPER::reset_counter ();
  60.  
  61.   $logindefs = &Users::Users::get_logindefs ();
  62.   $users = &Users::Users::get ();
  63.   $shells = &Users::Shells::get ();
  64.   $ecryptfs_support = (&Utils::File::locate_tool ("mount.ecryptfs") ne "")
  65.     && ($Utils::Backend::tool{"platform"} =~ /^debian/);
  66.  
  67.   return ($users, $shells, $$logindefs{"umin"},
  68.           $$logindefs{"umax"}, $$logindefs{"home_prefix"},
  69.           $$logindefs{"shell"}, $$logindefs{"group"},
  70.           $ecryptfs_support);
  71. }
  72.  
  73. sub set
  74. {
  75.   my ($self, @config) = @_;
  76.   $self->SUPER::reset_counter ();
  77.  
  78.   Users::Shells::set ($config[0]);
  79.   Users::Users::set_logindefs ({"umin"        => $config[2],
  80.                                 "umax"        => $config[3],
  81.                                 "home_prefix" => $config[4],
  82.                                 "shell"       => $config[5],
  83.                                 "group"       => $config[6]});
  84. }
  85.  
  86.  
  87. sub getFiles
  88. {
  89.   my ($self) = @_;
  90.   my ($files);
  91.  
  92.   $files = &Users::Users::get_files ();
  93.  
  94.   return ($files);
  95. }
  96.  
  97. my $config = UsersConfig->new ();
  98.  
  99. 1;
  100.