U '¡Dgºã@sÂUdZddlZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZd Zd d d d dgegdœZe ed<e e¡Zee eeddœdd„Zdd„Zeeedœdd„ZdS)zSSH Import ID: Import SSH idéN)ÚsubpÚutil)ÚCloud)ÚConfig)Ú MetaSchema)Úug_util)Ú PER_INSTANCEz ssh-import-idZcc_ssh_import_idZalpineZcosZdebianZubuntu)ÚidZdistrosZ frequencyZactivate_by_schema_keysÚmeta)ÚnameÚcfgÚcloudÚargsÚreturnc Cs˜t|dƒst d¡dSt t¡s0t d¡dSt|ƒdkrn|d}g}t|ƒdkr`|dd…}t||ƒdSt   ||j ¡\}}g}|  ¡D]ô\}} g} | dr°t  |dg¡} n2z | d} Wn$tk ràt d|¡YqŒYnXzt  | ¡} dd „| Dƒ} Wn&tk r$t d |¡YqŒYnXt| ƒs2qŒzt| |ƒWqŒtk r~} zt  td || ¡| | ¡W5d} ~ XYqŒXqŒt|ƒr”|d‚dS) NZ ssh_import_idzISkipping module named ssh_import_id, no 'ssh_import_id' directives found.zXssh-import-id is not installed, but module ssh_import_id is configured. Skipping module.réÚdefaultz+User %s is not configured for ssh_import_idcSsg|] }t|ƒ‘qS©)Ústr)Ú.0ÚirrúC/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_import_id.pyÚ Kszhandle..z5User %s is not correctly configured for ssh_import_idzssh-import-id failed for: %s %s)Úis_key_in_nested_dictÚLOGÚdebugrÚwhichÚSSH_IMPORT_ID_BINARYZwarningÚlenÚimport_ssh_idsrZnormalize_users_groupsZdistroÚitemsrZget_cfg_option_listÚ ExceptionZ uniq_mergeÚlogexcÚappend) r r r rÚuserÚidsZusersZ_groupsZelistZuser_cfgZ import_idsÚexcrrrÚhandle"sf ÿ ÿ        ÿ  ÿ r&c Csò|r|st d||¡dSzt |¡Wn&tk rN}z|‚W5d}~XYnXt d¡rnddd|tg|}n*t d¡rŠdd|tg|}nt d¡dSt d|¡ztj|d d Wn6tj k rì}zt   td |¡|‚W5d}~XYnXdS) Nz(empty user(%s) or ids(%s). not importingZsudoz--preserve-env=https_proxyz-HuZdoasz-uz:Neither sudo nor doas available! Unable to import SSH ids.zImporting SSH ids for user %s.F)Zcapturez*Failed to run command to import %s SSH ids) rrÚpwdÚgetpwnamÚKeyErrorrrrÚerrorZProcessExecutionErrorrr!)r$r#r%Úcmdrrrras@ ûú üû  r)ÚconfigÚ search_keyrcCsz| ¡D]l}||krdSt||tƒrs$      ü ??