MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyo
�
d�bc@s�ddlZddlZddlZddlZddlZddljjjZddl	jjj
Z
ddljjZddl
jjZddlmZddlmZejdej�Zdefd��YZdS(i����N(tOSUtilError(t
DefaultOSUtils5^\s*[A-F0-9]{8}(?:\-[A-F0-9]{4}){3}\-[A-F0-9]{12}\s*$t
OpenBSDOSUtilcBs�eZd�Zed��Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Ze
e
d
�Zddd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zded)d)dd�Z ed�Z!d dd!�Z"d"�Z#d#�Z$d$�Z%d%�Z&ed&��Z'd'�Z(ed(��Z)RS(*cCs)tt|�j�t|_t|_dS(N(tsuperRt__init__tTruetjit_enabledtFalset_scsi_disks_timeout_set(tself((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyR)s	cCsdS(Ns/usr/local/sbin((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_agent_bin_path.scCsDtjd�\}}|dks6tj|�dkr:dS|j�S(Nssysctl -n hw.uuidit(t	shellutiltrun_get_outputtUUID_PATTERNtmatchtNonetstrip(R	trettoutput((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_instance_id2s!cCs6tjddj|��|jd|gdt�dS(Ns/etc/mynames{}
thostnamet	log_error(tfileutilt
write_filetformatt_run_command_without_raisingR(R	R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytset_hostname8scCstjddt�S(Nsrcctl restart sshdtchk_err(RtrunR(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytrestart_ssh_service<scCstjdj|j�dt�S(Nsrcctl start {0}R(RRRtservice_nameR(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytstart_agent_service?scCstjdj|j�dt�S(Nsrcctl stop {0}R(RRRRR(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytstop_agent_serviceBscCs>tjdj|j�dt�tjdj|j�dt�S(Nschmod 0555 /etc/rc.d/{0}Rsrcctl enable {0}(RRRRR(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytregister_agent_serviceEscCstjdj|j�dt�S(Nsrcctl disable {0}R(RRRRR(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytunregister_agent_serviceIscCsb|j|�r"tjd|�n|jddg�|jdd|g�|j|dt�dS(Ns){0} is a system user. Will not delete it.ttouchs
/var/run/utmptuserdels-rtremove(tis_sys_usertloggerterrorRtconf_sudoerR(R	tusername((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytdel_accountLs
c	Cs+d}d}|s�tjj|�s=d}tj||�n|rUdj|�}ndj|�}tj||�tj|d�n�tjj|�r'y`tj|�}|j	d�}g|D]}||kr�|^q�}tj
|dj|��Wq'tk
r#}t
dj|���q'XndS(Ns/etc/doas.confspermit keepenv nopass root
spermit keepenv nopass {0}
spermit keepenv persist {0}
i�s
sFailed to remove sudoer: {0}(RtostpathtisfileRtappend_fileRtchmodt	read_filetsplitRtjointIOErrorR(	R	R+tnopasswdR&t	doas_conftdoastcontenttxterr((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyR*Ss(%	ii
cCs�|j|�r'tdj|���n|jdgd|ddj|��}|j�}|jdd||gddj|��dS(	Ns/User {0} is a system user. Will not set passwd.tencryptt	cmd_inputterr_msgs"Failed to encrypt password for {0}tusermods-psFailed to set password for {0}(R'RRt _run_command_raising_OSUtilErrorR(R	R+tpasswordtcrypt_idtsalt_lenRtpasswd_hash((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytchpasswdms	cCs7tjd�\}}|r3tdj|���ndS(Nsusermod -p "*" roots#Failed to delete root password: {0}(RR
RR(R	RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytdel_root_passwordws	cCs:|j�}|d|kr6|djdd�j�SdS(Niit:R(t
_get_net_infotreplacetupperR(R	tifnametdata((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt
get_if_mac}scCs|j�d S(Ni(RH(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_first_if�scCs(dj|||�}tj|dt�S(Nsroute add {0} {1} {2}R(RRRR(R	tnettmasktgatewaytcmd((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt	route_add�scCs)tjddt�}|dkr%tStS(Nsroute -n get defaultRi(RRRR(R	R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytis_missing_default_route�scCsdS(N((R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytis_dhcp_enabled�scCsdS(N((R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytstart_dhcp_service�scCsdS(N((R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytstop_dhcp_service�scCs�d}dj|j�d�}d}d}d}d}d}tjdj|��x
tj|�D]�}t|�j�}	||	krcd}
t}t	}x�|	j
�D]�}
|
j|�r�d}
t}t	}q�||
krQyH|
jd	�d
j
d�jd�}d
jd�|D��}
t	}WqXtk
rMtjdj|
��qXXq�||
kr�d|
krrt}qXyV|
jd	d�d
j
d�}tjj||�}|tjj�kr�t}nWqXtk
r�tjdj|
��qXXq�||
kr�tjdj|
||��|rX|
dk	rX|rX|
}tjdj|��qXq�q�WqcqcW|dk	r�tjdj|��n
tjd�|S(sE
        OpenBSD has a sligthly different lease file format.
        s/var/db/dhclient.leases.{}itleasesoption option-245texpiret}s%Y/%m/%d %H:%M:%S %Zs looking for leases in path [{0}]t i����t;RGt.css$|]}tt|d��VqdS(iN(tstrtint(t.0td((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pys	<genexpr>�sscould not parse '{0}'tneveris"could not parse expiry token '{0}'s%dhcp entry:{0}, 245:{1}, expired: {2}sfound endpoint [{0}]scached endpoint found [{0}]scached endpoint not foundN(RRRNR(tinfotglobtopentreadRRt
splitlinest
startswithR3RR4t
ValueErrorR)tdatetimetstrptimetutcnow(R	tendpointtpathglobtHEADER_LEASEt
HEADER_OPTIONt
HEADER_EXPIREtFOOTER_LEASEtFORMAT_DATETIMEt
lease_filetleasestcached_endpointthas_option_245texpiredtlinetipaddrt
expire_stringtexpire_date((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_dhcp_lease_endpoint�sb	%

		

'
cCsdS(N((R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytallow_dhcp_broadcast�scCstjdj|�dt�S(Ns$route add 255.255.255.255 -iface {0}R(RRRR(R	RK((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytset_route_for_dhcp_broadcast�scCs tjdj|�dt�dS(Ns'route delete 255.255.255.255 -iface {0}R(RRRR(R	RK((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytremove_route_for_dhcp_broadcast�scCs|jdddg�S(Ntpgreps-ntdhclient(t
_get_dhcp_pid(R	((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_dhcp_pid�ss/devcCsqd}xXgtj|�D]}tj||�^qD](}|dk	r5dj|jd��Sq5Wtd��dS(Nscd[0-9]cs/dev/{0}isFailed to get DVD device(R-tlistdirtreRRRtgroupR(R	tdev_dirtpatterntdevtdvd((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_dvd_device�s
5ic
	CsM|dkr|j�}n|dkr6tj�}ntjj|�sXtj|�nx�td|�D]�}|j	||dddddgdt
�}|dkr�tjd�dS||d	krht
jd
�d	}|j||�}	|	dk	r
tjd||	�dStjd||�tj|�qhqhW|rItd
��ndS(Nitoptions-otros-ttudfRsSuccessfully mounted DVDis/sbin/mounts{0} is mounted at {1}s$Mount DVD failed: retry={0}, ret={1}sFailed to mount DVD.(RR�tconftget_dvd_mount_pointR-R.tisdirtmakedirstrangetmountRR(RcRR
tget_mount_pointtwarnttimetsleepR(
R	t	max_retryRt
dvd_devicetmount_pointt
sleep_timetretrytretcodet	mountlisttexisting((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt	mount_dvd�s2		
cCsR|j�}tjdj|��}|rN|dkrNtdj|���ndS(Nscdio eject {0}isFailed to eject DVD: ret={0}(R�RRRR(R	RR�R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt	eject_dvdsicCs tjdj|�dt�dS(Ns/sbin/dhclient {0}R(RRRR(R	RKtretriestwait((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt
restart_ifscCsvtjd�\}}|r3tdj|���nyt|�ddSWn&tk
rqtdj|���nXdS(Nssysctl -n hw.physmemsFailed to get total memory: {0}i(RR
RRR_Ri(R	RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt
get_total_mems
cCsetjd�\}}|r*td��nyt|�SWn&tk
r`tdj|���nXdS(Nssysctl -n hw.ncpusFailed to get processor cores.sFailed to get total memory: {0}(RR
RR_RiR(R	RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_processor_coress
cCsdS(N((R	ttimeout((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytset_scsi_disks_timeout)scCs,|s
dStjdj|�dt�dkS(Ns	ps -p {0}Ri(RRRR(R	tpid((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytcheck_pid_alive,scCs@d}d}d}tjddt�\}}|rKtdj|���n|j�}|sltd��n|d}tjd|dt�\}}|r�tdj|���nxg|jd	�D]V}|jd
�dkr�|j�d}q�|jd
�dkr�|j�d}q�q�Wtjd|||�|||fS(s�
        There is no SIOCGIFCONF
        on OpenBSD - just parse ifconfig.
        Returns strings: iface, inet4_addr, and mac
        or 'None,None,None' if unable to parse.
        We will sleep and retry as the network must be up.
        Rs0ifconfig hvn | grep -E "^hvn.:" | sed "s/:.*//g"RsCan't find ether interface:{0}sCan't find ether interface.is	ifconfig s Can't get info for interface:{0}s
sinet i����islladdr sInterface info: ({0},{1},{2})(	RR
RRRR3tfindR(tverbose(tifacetinettmacRRtifacesRy((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyRH1s,	
cCs
dj|�S(s>
        Return device name attached to ide port 'n'.
        swd{0}(R(R	tport_id((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytdevice_for_ide_portUscCsdS(Ni((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pytget_total_cpu_ticks_since_boot[sN(*t__name__t
__module__RtstaticmethodR
RRRR R!R"R#R,RR*RERFRMRNRSRTRURVRWR}R~RR�R�R�RRR�R�R�R�R�R�R�RHR�R�(((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyR'sP									
									=							
		$	(R-R�R�RdRjt%azurelinuxagent.common.utils.fileutiltcommontutilsRt&azurelinuxagent.common.utils.shellutilRtazurelinuxagent.common.loggerR(tazurelinuxagent.common.confR�t azurelinuxagent.common.exceptionRt%azurelinuxagent.common.osutil.defaultRtcompilet
IGNORECASERR(((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/openbsd.pyt<module>s