sys-admin 1.8.0-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +204 -0
- data/Gemfile +2 -0
- data/LICENSE +177 -0
- data/MANIFEST.md +20 -0
- data/README.md +162 -0
- data/Rakefile +44 -0
- data/certs/djberg96_pub.pem +26 -0
- data/doc/sys-admin-unix.txt +162 -0
- data/doc/sys-admin-windows.txt +346 -0
- data/examples/example_groups.rb +27 -0
- data/examples/example_users.rb +41 -0
- data/lib/bsd/sys/admin.rb +262 -0
- data/lib/darwin/sys/admin.rb +244 -0
- data/lib/linux/sys/admin.rb +272 -0
- data/lib/sunos/sys/admin.rb +268 -0
- data/lib/sys/admin/common.rb +134 -0
- data/lib/sys/admin/custom.rb +16 -0
- data/lib/sys/admin.rb +24 -0
- data/lib/sys-admin.rb +1 -0
- data/lib/unix/sys/admin.rb +165 -0
- data/lib/windows/sys/admin.rb +1018 -0
- data/spec/sys_admin_unix_spec.rb +262 -0
- data/spec/sys_admin_windows_spec.rb +350 -0
- data/sys-admin.gemspec +44 -0
- data.tar.gz.sig +0 -0
- metadata +162 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: da216caeef1d2038bbbeace7ed087e6835ec210870a34f89653945ffa2245b72
|
4
|
+
data.tar.gz: 7c36e9ed782cb6be87cdc69cd94ff3c06894afb96cc54fa3db1af06fa48499dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ad2079f20c0d05e4d9d6efac82e560d88f6c78a248131135c7e1455ef02d84bbf0dc628a5913a21689c888be614f5b30b7ce4ab61c63bb9a77c6c44a174420c
|
7
|
+
data.tar.gz: b564a7e2cf651b86ecb08084b13813a33ac199707292fc56f7b3daad770cdd150358b7110dfb53c2913864ebb5d9ec25f1bcac30828c140748fcabfc59f8152f
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/CHANGES.md
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
## 1.8.0 - 26-Aug-2021
|
2
|
+
* Switched from test-unit to rspec, with some tests refactored. The Rakefile
|
3
|
+
and gemspec files were updated accordingly.
|
4
|
+
* The User and Group classes for the Windows implementation are now properly
|
5
|
+
scoped under Sys::Admin instead of just Sys.
|
6
|
+
* Fixed a bug in the get_user and get_group methods on Winodws where the WQL
|
7
|
+
it generates internally might not be correct.
|
8
|
+
|
9
|
+
## 1.7.6 - 24-Mar-2021
|
10
|
+
* Changed the implementation for `Admin.get_login` on Linux since the
|
11
|
+
underlying `getlogin` C function is unreliable, especially in certain
|
12
|
+
virtualized environments.
|
13
|
+
* Added win32-security back to the gemspec as a dependency for Windows.
|
14
|
+
I'm not sure why I removed it, and bundler definitely needs it.
|
15
|
+
* Fixed some private access modifiers that weren't actually doing anything.
|
16
|
+
|
17
|
+
## 1.7.5 - 30-Dec-2020
|
18
|
+
* Switched from rdoc to markdown since github isn't rendering rdoc properly.
|
19
|
+
|
20
|
+
## 1.7.4 - 19-Mar-2020
|
21
|
+
* Properly include a LICENSE file as per the Apache-2.0 license.
|
22
|
+
|
23
|
+
## 1.7.3 - 16-Jan-2020
|
24
|
+
* Add explicit .rdoc extension to various rdoc files so that they show up
|
25
|
+
better in github.
|
26
|
+
* Some formatting adjustments to the rdoc files.
|
27
|
+
|
28
|
+
## 1.7.2 - 28-Jan-2019
|
29
|
+
* Fixed the license name, was missing a hyphen.
|
30
|
+
* Fixed the homepage in the gemspec.
|
31
|
+
|
32
|
+
## 1.7.1 - 19-Mar-2018
|
33
|
+
* Fixed deprecation warnings in tests.
|
34
|
+
* Added gemspec metadata.
|
35
|
+
* Updated cert again, this one should last 10 years.
|
36
|
+
|
37
|
+
## 1.7.0 - 21-Feb-2018
|
38
|
+
* Changed the license to Apache 2.0.
|
39
|
+
* VERSION constant is now frozen.
|
40
|
+
* Ignore dependency warnings in gem:create task.
|
41
|
+
* Minor README updates.
|
42
|
+
* Updated cert.
|
43
|
+
|
44
|
+
## 1.6.4 - 6-Sep-2015
|
45
|
+
* Added a sys-admin.rb file for convenience.
|
46
|
+
* Set VERSION in a single place.
|
47
|
+
* Assume Rubygems 2.x for Rakefile tasks.
|
48
|
+
* This gem is now signed.
|
49
|
+
|
50
|
+
## 1.6.3 - 8-Mar-2014
|
51
|
+
* The Admin#get_group method now handles groups with very large numbers
|
52
|
+
of members more robustly.
|
53
|
+
|
54
|
+
## 1.6.2 - 11-Feb-2014
|
55
|
+
* The User#gid method is now supported on MS Windows. It returns the user's
|
56
|
+
primary group ID.
|
57
|
+
|
58
|
+
## 1.6.1 - 24-Jan-2014
|
59
|
+
* Added the Admin.add_group_member and Admin.remove_group member methods. These
|
60
|
+
let you add a user to a specific group. Thanks go to Alexey Kolyanov for the
|
61
|
+
idea and the code.
|
62
|
+
* Modified the Admin.configure_user method so that you don't need to know the
|
63
|
+
old password. Just pass a single string argument for the new password.
|
64
|
+
* Fixed a potential encoding issue for the Admin.get_login method on JRuby.
|
65
|
+
* Updated the gem:create task in the Rakefile.
|
66
|
+
* Added rake as a development dependency.
|
67
|
+
|
68
|
+
## 1.6.0 - 5-Jan-2013
|
69
|
+
* Converted code to use FFI. This mostly only affects the unix flavors.
|
70
|
+
* The Admin.users and Admin.groups methods no longer accept a block.
|
71
|
+
* Some test suite updates.
|
72
|
+
* Because all code is now pure Ruby, there is longer any need for two
|
73
|
+
separate gems. There is now a single, unified gem that works on all
|
74
|
+
supported platforms.
|
75
|
+
|
76
|
+
## 1.5.6 - 30-Jul-2011
|
77
|
+
* Fixed issue for non-gnu platforms where it would use the wrong function
|
78
|
+
prototype because the Ruby core team took it upon themselves to explicitly
|
79
|
+
defined _GNU_SOURCE in config.h in 1.8.7 and later for reasons that baffle me.
|
80
|
+
* Some tests on Windows are now skipped unless run with elevated security.
|
81
|
+
|
82
|
+
## 1.5.5 - 5-Jul-2011
|
83
|
+
* Modified lastlog handling, and ignore getpwent_r and getgrent_r, on AIX.
|
84
|
+
Thanks go to Rick Ohnemus for the spot and patches.
|
85
|
+
* Explicitly set spec.cpu on Windows to 'universal' in the gem creation task.
|
86
|
+
* Fixed a bug in the User.get_login and User.get_group methods where the query
|
87
|
+
being generated was incorrect if no options were passed. Thanks go to
|
88
|
+
Matthew Brown for the spot.
|
89
|
+
|
90
|
+
## 1.5.4 - 7-Oct-2010
|
91
|
+
* Prefer the getlastlogx() function over lastlog() where supported.
|
92
|
+
|
93
|
+
## 1.5.3 - 6-Oct-2010
|
94
|
+
* Refactored the Rakefile. The old installation tasks have been replaced
|
95
|
+
with gem build and install tasks. In addition, the platform handling has
|
96
|
+
been updated for MS Windows.
|
97
|
+
* Portions of the gemspec have been moved into the Rakefile gem tasks.
|
98
|
+
* Deploying the mingw gem by default for MS Windows now.
|
99
|
+
|
100
|
+
## 1.5.2 - 2-Aug-2009
|
101
|
+
* Now compatible with Ruby 1.9.x.
|
102
|
+
* Added test-unit as a development dependency.
|
103
|
+
|
104
|
+
## 1.5.1 - 23-Jul-2009
|
105
|
+
* Added the User#dir attribute. This attribute contains a user's home
|
106
|
+
directory if set, or nil if it isn't.
|
107
|
+
* User objects returned by the Admin.users method now include the uid.
|
108
|
+
Previously only the Admin.get_user method set it.
|
109
|
+
* Added win32-security as a dependency.
|
110
|
+
* Changed license to Artistic 2.0.
|
111
|
+
|
112
|
+
## 1.5.0 - 29-Mar-2009
|
113
|
+
* INTERFACE CHANGE (WINDOWS ONLY): The interface for MS Windows has undergone
|
114
|
+
a radical change. Most methods now accept a hash of options that are
|
115
|
+
passed directly to the underlying WMI class. Please see the documentation
|
116
|
+
for details.
|
117
|
+
* Now works on various BSD flavors.
|
118
|
+
* Added the User#groups method. This returns an array of groups that the
|
119
|
+
user belongs to. Suggestion inspired by Gonzalo Garramuno.
|
120
|
+
* Added the Group#members method. The returns an array of users that the
|
121
|
+
group contains.
|
122
|
+
* Changed User#class to User#access_class for UNIX flavors to avoid
|
123
|
+
conflicts with the Ruby core Object method.
|
124
|
+
* Added more tests and renamed the test files.
|
125
|
+
* Removed an unnecessary function call where a platform might try to
|
126
|
+
get lastlog information even if the lastlog.h or utmp.h headers couldn't
|
127
|
+
be found.
|
128
|
+
|
129
|
+
## 1.4.4 - 19-Nov-2008
|
130
|
+
* Added the User#uid method for MS Windows (which is just the user's relative
|
131
|
+
identifier).
|
132
|
+
* Now requires test-unit 2.x.
|
133
|
+
* Some updates to the test suite to take advantage of test-unit 2.x features.
|
134
|
+
* Some minor gemspec tweaks.
|
135
|
+
|
136
|
+
## 1.4.3 - 2-Mar-2008
|
137
|
+
* The block form of Admin.users now properly ensures that endpwent() is
|
138
|
+
called. Likewise, the block form of Admin.groups now properly ensures
|
139
|
+
that endgrent() is called. This would only have been an issue if you
|
140
|
+
broke out of the block before it terminated.
|
141
|
+
* The AdminError class is now Admin::Error.
|
142
|
+
* Some internal directory layout changes.
|
143
|
+
|
144
|
+
## 1.4.2 - 26-Jun-2007
|
145
|
+
* Fixed a bug in the Admin.get_login method where it would return junk
|
146
|
+
if the underlying getlogin() function failed (Unix). Thanks go to Gonzalo
|
147
|
+
Garramuno for the spot. This bug also resulted in some refactoring of the
|
148
|
+
underlying C code.
|
149
|
+
* Removed the install.rb file. The logic in that file has been moved directly
|
150
|
+
into the Rakefile.
|
151
|
+
|
152
|
+
## 1.4.1 - 21-Mar-2007
|
153
|
+
* Bug fix for OS X. Thanks go to an anonymous user for the spot.
|
154
|
+
* Added a Rakefile. Building, testing and installing should now use the
|
155
|
+
Rake tasks (for non-gem installs).
|
156
|
+
* Much more inline documentation, especially for User and Group attributes.
|
157
|
+
|
158
|
+
## 1.4.0 - 20-Jan-2007
|
159
|
+
* Added the following methods: add_local_user, config_local_user,
|
160
|
+
delete_local_user, add_global_group, config_global_group, and
|
161
|
+
delete_global_group. MS Windows only at the moment.
|
162
|
+
* Added corresponding tests.
|
163
|
+
* Added much more inline documentation.
|
164
|
+
* Major refactoring of the get_lastlog_info helper function in admin.h. This
|
165
|
+
fixed a major bug in some flavors of Linux where the Admin.users method
|
166
|
+
could go into an infinite loop. It also fixed some minor bugs where console
|
167
|
+
and host values were sometimes filled with junk characters.
|
168
|
+
* Added the User#change attribute, and a check for the pw_change struct member
|
169
|
+
in the extconf.rb file.
|
170
|
+
* The User#expire attribute is now handled as a Time object instead of an
|
171
|
+
integer.
|
172
|
+
* Renamed tc_win32.rb to tc_windows.rb
|
173
|
+
|
174
|
+
## 1.3.1 - 29-Jun-2005
|
175
|
+
* Fixed a bug where the inability to read the lastlog file caused an error.
|
176
|
+
From now on that error is ignored, and the lastlog attributes of the User
|
177
|
+
object are set to nil.
|
178
|
+
* Added a beta version of Admin.delete_user (Windows only).
|
179
|
+
|
180
|
+
## 1.3.0 - 3-Jun-2005
|
181
|
+
* Bug fixes for Linux.
|
182
|
+
* Removed the version.h file - no longer needed since the Win32 version is
|
183
|
+
pure Ruby.
|
184
|
+
|
185
|
+
## 1.2.0 - 30-Apr-2005
|
186
|
+
* Replaced the Win32 version with a pure Ruby version that uses Win32API and
|
187
|
+
win32ole + WMI.
|
188
|
+
* The LocalGroup class no longer exists in the Win32 version. Instead, it is
|
189
|
+
now an attribute of a Group object. The issue was forced by WMI.
|
190
|
+
* The default for users and groups on Win32 systems is now local rather than
|
191
|
+
global. See the documentation for why you probably don't want to iterate
|
192
|
+
over global accounts.
|
193
|
+
* Corresponding doc changes and test suite changes.
|
194
|
+
|
195
|
+
## 1.1.0 - 1-Apr-2005
|
196
|
+
* Fixed bug where a segfault could occur when trying to retrieve a user or
|
197
|
+
group by an ID that didn't exist (Unix).
|
198
|
+
* Added tests for intentional failures.
|
199
|
+
* Added lastlog information tothe User class (Unix).
|
200
|
+
* Modified the way User objects are created internally (Unix).
|
201
|
+
* Fixed a bug in the User#shell attribute (Unix).
|
202
|
+
|
203
|
+
## 1.0.0 - 25-Mar-2005
|
204
|
+
* Initial release
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
data/MANIFEST.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
* sys-admin.gemspec
|
2
|
+
* CHANGES.md
|
3
|
+
* LICENSE
|
4
|
+
* MANIFEST.md
|
5
|
+
* README.md
|
6
|
+
* Gemfile
|
7
|
+
* Rakefile
|
8
|
+
* certs/djberg96_pub.pem
|
9
|
+
* examples/groups.rb
|
10
|
+
* examples/users.rb
|
11
|
+
* lib/sys/admin.rb
|
12
|
+
* lib/darwin/sys/admin.rb
|
13
|
+
* lib/linux/sys/admin.rb
|
14
|
+
* lib/bsd/sys/admin.rb
|
15
|
+
* lib/sunos/sys/admin.rb
|
16
|
+
* lib/sys/admin/common.rb
|
17
|
+
* lib/sys/admin/custom.rb
|
18
|
+
* test/test_sys_admin.rb
|
19
|
+
* test/test_sys_admin_unix.rb
|
20
|
+
* test/test_sys_admin_windows.rb
|
data/README.md
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
## Description
|
2
|
+
The sys-admin library is a unified, cross platform replacement for the Etc module.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
`gem install sys-admin`
|
6
|
+
|
7
|
+
## Adding the trusted cert
|
8
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-admin/main/certs/djberg96_pub.pem)`
|
9
|
+
|
10
|
+
## Synopsis
|
11
|
+
```ruby
|
12
|
+
require 'sys/admin' # or sys-admin
|
13
|
+
include Sys
|
14
|
+
|
15
|
+
# Returns an Array of User objects
|
16
|
+
a = Admin.users
|
17
|
+
|
18
|
+
# Returns an Array of Group objects
|
19
|
+
g = Admin.groups
|
20
|
+
|
21
|
+
# Get information about a particular user
|
22
|
+
p Admin.get_user("nobody")
|
23
|
+
p Admin.get_user("nobody", :localaccount => true)
|
24
|
+
|
25
|
+
# Get information about a particular group
|
26
|
+
p Admin.get_group("adm")
|
27
|
+
p Admin.get_group("adm", :localaccount => true)
|
28
|
+
```
|
29
|
+
|
30
|
+
## Admin
|
31
|
+
`Admin.get_login`
|
32
|
+
|
33
|
+
Returns the user name (only) of the current login.
|
34
|
+
|
35
|
+
```
|
36
|
+
Admin.get_user(name, options = {})
|
37
|
+
Admin.get_user(uid, options = {})
|
38
|
+
```
|
39
|
+
|
40
|
+
Returns a User object based on `name` or `uid`. The `options` hash is
|
41
|
+
for MS Windows only, and allows you to restrict the search based on the
|
42
|
+
options you provide, e.g. 'domain' or 'localaccount'.
|
43
|
+
|
44
|
+
```
|
45
|
+
Admin.get_group(name, options = {})
|
46
|
+
Admin.get_group(gid, options = {})
|
47
|
+
```
|
48
|
+
|
49
|
+
Returns a Group object based on `name` or `uid`. The `options` hash is
|
50
|
+
for MS Windows only, and allows you to restrict the search based on the
|
51
|
+
options you provide, e.g. 'domain' or 'localaccount'.
|
52
|
+
|
53
|
+
`Admin.groups(options = {})`
|
54
|
+
|
55
|
+
Returns an Array of Group objects.
|
56
|
+
|
57
|
+
The `options` hash is for MS Windows only, and allows you to restrict the
|
58
|
+
search based on the options you provide, e.g. 'domain' or 'localaccount'.
|
59
|
+
|
60
|
+
`Admin.users(options = {})`
|
61
|
+
|
62
|
+
Returns an Array of User objects.
|
63
|
+
|
64
|
+
The `options` hash is for MS Windows only, and allows you to restrict the
|
65
|
+
search based on the options you provide, e.g. 'domain' or 'localaccount'.
|
66
|
+
|
67
|
+
## User class
|
68
|
+
### User (Windows)
|
69
|
+
The User class has the following attributes on MS Windows systems:
|
70
|
+
|
71
|
+
* account_type
|
72
|
+
* caption
|
73
|
+
* description
|
74
|
+
* domain
|
75
|
+
* password
|
76
|
+
* full_name
|
77
|
+
* gid
|
78
|
+
* install_date
|
79
|
+
* name
|
80
|
+
* sid
|
81
|
+
* status
|
82
|
+
* disabled?
|
83
|
+
* local?
|
84
|
+
* lockout?
|
85
|
+
* password_changeable?
|
86
|
+
* password_expires?
|
87
|
+
* password_required?
|
88
|
+
* uid
|
89
|
+
|
90
|
+
### User (Unix)
|
91
|
+
The User class has the following attributes on Unix systems:
|
92
|
+
|
93
|
+
* name
|
94
|
+
* passwd
|
95
|
+
* uid
|
96
|
+
* gid
|
97
|
+
* dir
|
98
|
+
* shell
|
99
|
+
* gecos
|
100
|
+
* quota
|
101
|
+
* age
|
102
|
+
* class
|
103
|
+
* comment
|
104
|
+
* change
|
105
|
+
* expire
|
106
|
+
|
107
|
+
## Group Classes
|
108
|
+
### Group (Windows)
|
109
|
+
The Group class has the following attributes on MS Windows systems:
|
110
|
+
|
111
|
+
* caption
|
112
|
+
* description
|
113
|
+
* domain
|
114
|
+
* install_date
|
115
|
+
* name
|
116
|
+
* sid
|
117
|
+
* status
|
118
|
+
* gid
|
119
|
+
* local?
|
120
|
+
|
121
|
+
### Group (Unix)
|
122
|
+
The Group class has the following attributes on Unix systems:
|
123
|
+
|
124
|
+
* name
|
125
|
+
* gid
|
126
|
+
* members
|
127
|
+
* passwd
|
128
|
+
|
129
|
+
## Error Classes
|
130
|
+
`Admin::Error < StandardError`
|
131
|
+
|
132
|
+
Raised if anything goes wrong with any of the above methods.
|
133
|
+
|
134
|
+
## Developer's Notes
|
135
|
+
### MS Windows
|
136
|
+
The Windows version now uses a win32ole + WMI approach to getting
|
137
|
+
information. This means that the WMI service must be running on the
|
138
|
+
target machine in order to work (which it is, by default).
|
139
|
+
|
140
|
+
### UNIX
|
141
|
+
The underlying implementation is similar to core Ruby's Etc implementation.
|
142
|
+
But, in addition to the different interface, I use the re-entrant version
|
143
|
+
of the appropriate functions when available.
|
144
|
+
|
145
|
+
## Future Plans
|
146
|
+
* Make the User and Group objects comparable.
|
147
|
+
* Add ability to add, configure and delete users on Unix platforms.
|
148
|
+
|
149
|
+
## Known Bugs
|
150
|
+
None that I'm aware of. If you find any, please log them on the project page at:
|
151
|
+
|
152
|
+
https://github.com/djberg96/sys-admin
|
153
|
+
|
154
|
+
## License
|
155
|
+
Apache-2.0
|
156
|
+
|
157
|
+
## Copyright
|
158
|
+
(C) 2005-2020, Daniel J. Berger
|
159
|
+
All Rights Reserved
|
160
|
+
|
161
|
+
## Author
|
162
|
+
Daniel J. Berger
|