Project

General

Profile

« Previous | Next » 

Revision 49eba660

Added by Viktor Gurov over 3 years ago

Fix SSH keys permissions on restore. Fixes #12637

View differences:

src/etc/inc/config.lib.inc
329 329
		$conf = & $config;
330 330
	}
331 331

  
332
	$oldmask = umask();
332 333
	foreach ($conf["sshdata"]["sshkeyfile"] as $sshkey) {
333 334
		$keypath = "{$sshConfigDir}/{$sshkey['filename']}";
335
		if (strstr($sshkey['filename'], 'pub')) {
336
			umask(0133);
337
		} else {
338
			umask(0177);
339
		}
334 340
		if (file_put_contents($keypath, gzinflate(base64_decode($sshkey['xmldata']))) === false) {
335 341
			log_error(sprintf(gettext("Cannot write %s"), $sshkey['filename']));
336 342
			continue;
337 343
		}
338 344
	}
345
	umask($oldmask);
339 346
}
340 347

  
341 348
/****f* config/parse_config_bootup

Also available in: Unified diff