Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/user/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/user/management.pyc


Tc@sdddlZddlZddlZddlmZddlmZmZdefdYZ	dS(iN(tmd5crypt(tUserManagementErrortUserProvidertUserManagementcBseZdZddZdZdZdZdddddddZdZ	dZ
edZd	Z
d
ZdZdZd
ZdZRS(sManage system users and groups.cCs|pt|_dS(N(Rt	_provider(tselftprovider((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyt__init__sc	Cstjd|d||pd|p(d|p1df}	d|dd|	g}
|r{|
jdt|jj|gn|j|
\}}|dkrtd	||fn|j|||r|jd
|dg\}}
|dkrtd||
fq||
7}n|S(
sAdd C{username} to the computer.

        @raises UserManagementError: Raised when C{adduser} fails.
        @raises UserManagementError: Raised when C{passwd} fails.
        sAdding user %s.s%s,%s,%s,%sttaddusers--disabled-passwords--gecoss--gidisError adding user %s.
%stpasswds-es(Error resetting password for user %s.
%s(	tloggingtinfotextendtstrRtget_gidt
call_popenRt
_set_password(Rtusernametnametpasswordtrequire_password_resettprimary_group_nametlocationt
work_phonet
home_phonetgecostcommandtresulttoutputt
new_output((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytadd_users(	
cCs|jd}|jd}tjdjdd }tj||}|jdd||g\}}|dkrtd||fn|S(	Ntasciiitbase64itusermods-pis&Error setting password for user %s.
%s(tencodetosturandomRRR(RRRtsalttcryptedRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyR3s!cCsk|jj|}ddt||g}|j|\}}|dkrgtd|||fn|S(NR"s-gis+Error setting primary group to %d for%s.
%s(RRRRR(RRt	groupnametprimary_gidRRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyt_set_primary_group?scCs|jj|}tjd|||r>|j||n|rW|j||ndg}	xWd|fd|fd|fd|fgD]+\}
}|d
k	r|	|
|g7}	qqWt|	dkr|j|	|g\}}
|dkr
t	d	||
fn|
Sd
S(s/Update details for the account matching C{uid}.s#Updating data for user %s (UID %d).tchfns-rs-fs-ws-hiis%Error setting details for user %s.
%sN(
Rtget_uidRRRR*tNonetlenRR(RRRRRtwork_numberthome_numberRtuidRtoptiontvalueRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytset_user_detailsIs"	"cCsl|jj|}tjd|||jdd|g\}}|dkrhtd||fndS(sX
        Lock the account matching C{username} to prevent them from logging in.
        sLocking out user %s (UID %d).R"s-LisError locking user %s.
%sN(RR,RRRR(RRR1RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyt	lock_userbscCsl|jj|}tjd|||jdd|g\}}|dkrhtd||fn|S(s(Unlock the account matching C{username}.sUnlocking user %s (UID %d).R"s-UisError unlocking user %s.
%s(RR,RRRR(RRR1RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytunlock_usermscCs|jj|}d|g}|rGtjd|||jdntjd|||j|\}}|dkrtd|||fn|S(s:Remove the account matching C{username} from the computer.tdelusers<Removing user %s (UID %d) and deleting their home directory.s
--remove-homes@Removing user %s (UID %d) without deleting their home directory.is#Error removing user %s (UID %d).
%s(RR,RRtappendRR(RRtdelete_homeR1RRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytremove_userxs	
	
cCsTtjd||jd|g\}}|dkrPtd||fn|S(s1Add C{group} with the C{addgroup} system command.sAdding group %s.taddgroupisError adding group %s.
%s(RRRR(RR(RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyt	add_groupscCs~|jj|}tjd|||dd||g}|j|\}}|dkrztd||||fn|S(s-Update details for the group matching C{gid}.s!Renaming group %s (GID %d) to %s.tgroupmods-nis*Error renaming group %s (GID %d) to %s.
%s(RRRRRR(RR(tnew_nametgidRRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytset_group_detailss	
	cCs|jj|}|jj|}tjd|||||jdd||g\}}|dkrtd|||||fn|S(s
        Add the user matching C{username} to the group matching C{groupname}
        with the C{gpasswd} system command.
        s-Adding user %s (UID %d) to group %s (GID %d).tgpasswds-ais6Error adding user %s (UID %d) to group %s (GID %d).
%s(RR,RRRRR(RRR(R1R?RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytadd_group_members	cCs|jj|}|jj|}tjd|||||jdd||g\}}|dkrtd|||||fn|S(s
        Remove the user matching C{username} from the group matching
        C{groupname} with the C{gpasswd} system command.
        s1Removing user %s (UID %d) from group %s (GID %d).RAs-dis;Error removing user %s (UID %d) from group %s (GID (%d).
%s(RR,RRRRR(RRR(R1R?RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytremove_group_members		cCsl|jj|}tjd|||jd|g\}}|dkrhtd|||fn|S(s;Remove the account matching C{groupname} from the computer.sRemoving group %s (GID %d).tgroupdelis$Error removing group %s (GID %d).
%s(RRRRRR(RR(R?RR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pytremove_groupscCsI|jj|dtjdtj}|jj}|j}||fS(Ntstdouttstderr(Rtpopent
subprocesstPIPEtSTDOUTRFtreadtwait(RtargsRHRR((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyRs
N(t__name__t
__module__t__doc__R-RRRR*R4R5R6tFalseR:R<R@RBRCRER(((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyRs"			
						
			
(
R$RRIt
landscape.libRtlandscape.user.providerRRtobjectR(((s=/usr/lib/python2.7/dist-packages/landscape/user/management.pyt<module>s