MCPcopy Create free account
hub / github.com/coreutils/coreutils / cp_options_default

Function cp_options_default

src/copy.c:2827–2847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2825/* Set *X to the default options for a value of type struct cp_options. */
2826
2827extern void
2828cp_options_default (struct cp_options *x)
2829{
2830 memset (x, 0, sizeof *x);
2831#ifdef PRIV_FILE_CHOWN
2832 {
2833 priv_set_t *pset = priv_allocset ();
2834 if (!pset)
2835 xalloc_die ();
2836 if (getppriv (PRIV_EFFECTIVE, pset) == 0)
2837 {
2838 x->chown_privileges = priv_ismember (pset, PRIV_FILE_CHOWN);
2839 x->owner_privileges = priv_ismember (pset, PRIV_FILE_OWNER);
2840 }
2841 priv_freeset (pset);
2842 }
2843#else
2844 x->chown_privileges = x->owner_privileges = (geteuid () == ROOT_UID);
2845#endif
2846 x->rename_errno = -1;
2847}
2848
2849/* Return true if it's OK for chown to fail, where errno is
2850 the error number that chown failed with and X is the copying

Callers 3

cp_option_initFunction · 0.85
cp_option_initFunction · 0.85
cp_option_initFunction · 0.85

Calls 1

xalloc_dieFunction · 0.85

Tested by

no test coverage detected