View | Details | Raw Unified | Return to bug 1409 | Differences between
and this patch

Collapse All | Expand All

(-)../openssh-4.7p1/config.h.in (+12 lines)
Lines 56-61 Link Here
56
/* Define if your snprintf is busted */
56
/* Define if your snprintf is busted */
57
#undef BROKEN_SNPRINTF
57
#undef BROKEN_SNPRINTF
58
58
59
/* platform uses an in-memory credentials cache */
60
#undef USE_CCAPI
61
62
/* platform has a Security Authorization Session API */
63
#undef USE_SECURITY_SESSION_API
64
65
/* Define to 1 if you have the `copyfile' function. */
66
#undef HAVE_COPYFILE
67
68
/* Define to 1 if you have the <copyfile.h> header file. */
69
#undef HAVE_COPYFILE_H
70
59
/* updwtmpx is broken (if present) */
71
/* updwtmpx is broken (if present) */
60
#undef BROKEN_UPDWTMPX
72
#undef BROKEN_UPDWTMPX
61
73
(-)../openssh-4.7p1/configure (+253 lines)
Lines 28390-28395 Link Here
28390
CFLAGS="$CFLAGS $werror_flags"
28390
CFLAGS="$CFLAGS $werror_flags"
28391
28391
28392
28392
28393
for ac_func in copyfile
28394
do
28395
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
28396
echo "$as_me:$LINENO: checking for $ac_func" >&5
28397
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
28398
if eval "test \"\${$as_ac_var+set}\" = set"; then
28399
  echo $ECHO_N "(cached) $ECHO_C" >&6
28400
else
28401
  cat >conftest.$ac_ext <<_ACEOF
28402
/* confdefs.h.  */
28403
_ACEOF
28404
cat confdefs.h >>conftest.$ac_ext
28405
cat >>conftest.$ac_ext <<_ACEOF
28406
/* end confdefs.h.  */
28407
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
28408
   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
28409
#define $ac_func innocuous_$ac_func
28410
28411
/* System header to define __stub macros and hopefully few prototypes,
28412
    which can conflict with char $ac_func (); below.
28413
    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
28414
    <limits.h> exists even on freestanding compilers.  */
28415
28416
#ifdef __STDC__
28417
# include <limits.h>
28418
#else
28419
# include <assert.h>
28420
#endif
28421
28422
#undef $ac_func
28423
28424
/* Override any gcc2 internal prototype to avoid an error.  */
28425
#ifdef __cplusplus
28426
extern "C"
28427
{
28428
#endif
28429
/* We use char because int might match the return type of a gcc2
28430
   builtin and then its argument prototype would still apply.  */
28431
char $ac_func ();
28432
/* The GNU C library defines this for functions which it implements
28433
    to always fail with ENOSYS.  Some functions are actually named
28434
    something starting with __ and the normal name is an alias.  */
28435
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
28436
choke me
28437
#else
28438
char (*f) () = $ac_func;
28439
#endif
28440
#ifdef __cplusplus
28441
}
28442
#endif
28443
28444
int
28445
main ()
28446
{
28447
return f != $ac_func;
28448
  ;
28449
  return 0;
28450
}
28451
_ACEOF
28452
rm -f conftest.$ac_objext conftest$ac_exeext
28453
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
28454
  (eval $ac_link) 2>conftest.er1
28455
  ac_status=$?
28456
  grep -v '^ *+' conftest.er1 >conftest.err
28457
  rm -f conftest.er1
28458
  cat conftest.err >&5
28459
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28460
  (exit $ac_status); } &&
28461
	 { ac_try='test -z "$ac_c_werror_flag"
28462
			 || test ! -s conftest.err'
28463
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
28464
  (eval $ac_try) 2>&5
28465
  ac_status=$?
28466
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28467
  (exit $ac_status); }; } &&
28468
	 { ac_try='test -s conftest$ac_exeext'
28469
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
28470
  (eval $ac_try) 2>&5
28471
  ac_status=$?
28472
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28473
  (exit $ac_status); }; }; then
28474
  eval "$as_ac_var=yes"
28475
else
28476
  echo "$as_me: failed program was:" >&5
28477
sed 's/^/| /' conftest.$ac_ext >&5
28478
28479
eval "$as_ac_var=no"
28480
fi
28481
rm -f conftest.err conftest.$ac_objext \
28482
      conftest$ac_exeext conftest.$ac_ext
28483
fi
28484
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
28485
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
28486
if test `eval echo '${'$as_ac_var'}'` = yes; then
28487
  cat >>confdefs.h <<_ACEOF
28488
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
28489
_ACEOF
28490
28491
fi
28492
done
28493
28494
28495
for ac_header in copyfile.h
28496
do
28497
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
28498
if eval "test \"\${$as_ac_Header+set}\" = set"; then
28499
  echo "$as_me:$LINENO: checking for $ac_header" >&5
28500
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
28501
if eval "test \"\${$as_ac_Header+set}\" = set"; then
28502
  echo $ECHO_N "(cached) $ECHO_C" >&6
28503
fi
28504
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
28505
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
28506
else
28507
  # Is the header compilable?
28508
echo "$as_me:$LINENO: checking $ac_header usability" >&5
28509
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
28510
cat >conftest.$ac_ext <<_ACEOF
28511
/* confdefs.h.  */
28512
_ACEOF
28513
cat confdefs.h >>conftest.$ac_ext
28514
cat >>conftest.$ac_ext <<_ACEOF
28515
/* end confdefs.h.  */
28516
$ac_includes_default
28517
#include <$ac_header>
28518
_ACEOF
28519
rm -f conftest.$ac_objext
28520
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
28521
  (eval $ac_compile) 2>conftest.er1
28522
  ac_status=$?
28523
  grep -v '^ *+' conftest.er1 >conftest.err
28524
  rm -f conftest.er1
28525
  cat conftest.err >&5
28526
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28527
  (exit $ac_status); } &&
28528
	 { ac_try='test -z "$ac_c_werror_flag"
28529
			 || test ! -s conftest.err'
28530
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
28531
  (eval $ac_try) 2>&5
28532
  ac_status=$?
28533
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28534
  (exit $ac_status); }; } &&
28535
	 { ac_try='test -s conftest.$ac_objext'
28536
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
28537
  (eval $ac_try) 2>&5
28538
  ac_status=$?
28539
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28540
  (exit $ac_status); }; }; then
28541
  ac_header_compiler=yes
28542
else
28543
  echo "$as_me: failed program was:" >&5
28544
sed 's/^/| /' conftest.$ac_ext >&5
28545
28546
ac_header_compiler=no
28547
fi
28548
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
28549
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
28550
echo "${ECHO_T}$ac_header_compiler" >&6
28551
28552
# Is the header present?
28553
echo "$as_me:$LINENO: checking $ac_header presence" >&5
28554
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
28555
cat >conftest.$ac_ext <<_ACEOF
28556
/* confdefs.h.  */
28557
_ACEOF
28558
cat confdefs.h >>conftest.$ac_ext
28559
cat >>conftest.$ac_ext <<_ACEOF
28560
/* end confdefs.h.  */
28561
#include <$ac_header>
28562
_ACEOF
28563
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
28564
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
28565
  ac_status=$?
28566
  grep -v '^ *+' conftest.er1 >conftest.err
28567
  rm -f conftest.er1
28568
  cat conftest.err >&5
28569
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
28570
  (exit $ac_status); } >/dev/null; then
28571
  if test -s conftest.err; then
28572
    ac_cpp_err=$ac_c_preproc_warn_flag
28573
    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
28574
  else
28575
    ac_cpp_err=
28576
  fi
28577
else
28578
  ac_cpp_err=yes
28579
fi
28580
if test -z "$ac_cpp_err"; then
28581
  ac_header_preproc=yes
28582
else
28583
  echo "$as_me: failed program was:" >&5
28584
sed 's/^/| /' conftest.$ac_ext >&5
28585
28586
  ac_header_preproc=no
28587
fi
28588
rm -f conftest.err conftest.$ac_ext
28589
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
28590
echo "${ECHO_T}$ac_header_preproc" >&6
28591
28592
# So?  What about this header?
28593
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
28594
  yes:no: )
28595
    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
28596
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
28597
    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
28598
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
28599
    ac_header_preproc=yes
28600
    ;;
28601
  no:yes:* )
28602
    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
28603
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
28604
    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
28605
echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
28606
    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
28607
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
28608
    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
28609
echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
28610
    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
28611
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
28612
    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
28613
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
28614
    (
28615
      cat <<\_ASBOX
28616
## ------------------------------------------- ##
28617
## Report this to openssh-unix-dev@mindrot.org ##
28618
## ------------------------------------------- ##
28619
_ASBOX
28620
    ) |
28621
      sed "s/^/$as_me: WARNING:     /" >&2
28622
    ;;
28623
esac
28624
echo "$as_me:$LINENO: checking for $ac_header" >&5
28625
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
28626
if eval "test \"\${$as_ac_Header+set}\" = set"; then
28627
  echo $ECHO_N "(cached) $ECHO_C" >&6
28628
else
28629
  eval "$as_ac_Header=\$ac_header_preproc"
28630
fi
28631
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
28632
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
28633
28634
fi
28635
if test `eval echo '${'$as_ac_Header'}'` = yes; then
28636
  cat >>confdefs.h <<_ACEOF
28637
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
28638
_ACEOF
28639
28640
fi
28641
28642
done
28643
28644
28645
28393
ac_config_files="$ac_config_files Makefile buildpkg.sh opensshd.init openssh.xml openbsd-compat/Makefile openbsd-compat/regress/Makefile scard/Makefile ssh_prng_cmds survey.sh"
28646
ac_config_files="$ac_config_files Makefile buildpkg.sh opensshd.init openssh.xml openbsd-compat/Makefile openbsd-compat/regress/Makefile scard/Makefile ssh_prng_cmds survey.sh"
28394
28647
28395
cat >confcache <<\_ACEOF
28648
cat >confcache <<\_ACEOF
(-)../openssh-4.7p1/configure.ac (+3 lines)
Lines 3982-3987 Link Here
3982
dnl Add now.
3982
dnl Add now.
3983
CFLAGS="$CFLAGS $werror_flags"
3983
CFLAGS="$CFLAGS $werror_flags"
3984
3984
3985
AC_CHECK_FUNCS(copyfile)
3986
AC_CHECK_HEADERS(copyfile.h)
3987
3985
AC_EXEEXT
3988
AC_EXEEXT
3986
AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
3989
AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
3987
	openbsd-compat/Makefile openbsd-compat/regress/Makefile \
3990
	openbsd-compat/Makefile openbsd-compat/regress/Makefile \
(-)../openssh-4.7p1/scp.1 (-1 / +3 lines)
Lines 20-26 Link Here
20
.Sh SYNOPSIS
20
.Sh SYNOPSIS
21
.Nm scp
21
.Nm scp
22
.Bk -words
22
.Bk -words
23
.Op Fl 1246BCpqrv
23
.Op Fl 1246BCEpqrv
24
.Op Fl c Ar cipher
24
.Op Fl c Ar cipher
25
.Op Fl F Ar ssh_config
25
.Op Fl F Ar ssh_config
26
.Op Fl i Ar identity_file
26
.Op Fl i Ar identity_file
Lines 87-92 Link Here
87
flag to
87
flag to
88
.Xr ssh 1
88
.Xr ssh 1
89
to enable compression.
89
to enable compression.
90
.It Fl E
91
Preserves extended attributes, resource forks, and ACLs.  Requires both ends to be running Mac OS X 10.4 or later.
90
.It Fl c Ar cipher
92
.It Fl c Ar cipher
91
Selects the cipher to use for encrypting the data transfer.
93
Selects the cipher to use for encrypting the data transfer.
92
This option is directly passed to
94
This option is directly passed to
(-)../openssh-4.7p1/scp.c (+122 lines)
Lines 107-112 Link Here
107
#include "misc.h"
107
#include "misc.h"
108
#include "progressmeter.h"
108
#include "progressmeter.h"
109
109
110
#ifdef HAVE_COPYFILE_H
111
#include <libgen.h>
112
#include <copyfile.h>
113
#endif
114
110
extern char *__progname;
115
extern char *__progname;
111
116
112
int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout);
117
int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout);
Lines 134-139 Link Here
134
/* This is used to store the pid of ssh_program */
139
/* This is used to store the pid of ssh_program */
135
pid_t do_cmd_pid = -1;
140
pid_t do_cmd_pid = -1;
136
141
142
#ifdef HAVE_COPYFILE
143
int copy_xattr = 0;
144
int md_flag = 0;
145
#endif
146
147
137
static void
148
static void
138
killchild(int signo)
149
killchild(int signo)
139
{
150
{
Lines 313-319 Link Here
313
	addargs(&args, "-oClearAllForwardings yes");
324
	addargs(&args, "-oClearAllForwardings yes");
314
325
315
	fflag = tflag = 0;
326
	fflag = tflag = 0;
327
#if HAVE_COPYFILE
328
	while ((ch = getopt(argc, argv, "dfl:prtvBCEc:i:P:q1246S:o:F:")) != -1)
329
#else
316
	while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1)
330
	while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1)
331
#endif
317
		switch (ch) {
332
		switch (ch) {
318
		/* User-visible flags. */
333
		/* User-visible flags. */
319
		case '1':
334
		case '1':
Lines 359-364 Link Here
359
			showprogress = 0;
374
			showprogress = 0;
360
			break;
375
			break;
361
376
377
#ifdef HAVE_COPYFILE
378
		case 'E':
379
			copy_xattr = 1;
380
			break;
381
#endif
362
		/* Server options. */
382
		/* Server options. */
363
		case 'd':
383
		case 'd':
364
			targetshouldbedirectory = 1;
384
			targetshouldbedirectory = 1;
Lines 408-414 Link Here
408
	remin = remout = -1;
428
	remin = remout = -1;
409
	do_cmd_pid = -1;
429
	do_cmd_pid = -1;
410
	/* Command to be executed on remote system using "ssh". */
430
	/* Command to be executed on remote system using "ssh". */
431
#if HAVE_COPYFILE
432
	(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s%s",
433
	    copy_xattr ? " -E" : "",
434
#else
411
	(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
435
	(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
436
#endif
412
	    verbose_mode ? " -v" : "",
437
	    verbose_mode ? " -v" : "",
413
	    iamrecursive ? " -r" : "", pflag ? " -p" : "",
438
	    iamrecursive ? " -r" : "", pflag ? " -p" : "",
414
	    targetshouldbedirectory ? " -d" : "");
439
	    targetshouldbedirectory ? " -d" : "");
Lines 587-592 Link Here
587
	int fd = -1, haderr, indx;
612
	int fd = -1, haderr, indx;
588
	char *last, *name, buf[2048], encname[MAXPATHLEN];
613
	char *last, *name, buf[2048], encname[MAXPATHLEN];
589
	int len;
614
	int len;
615
#if HAVE_COPYFILE
616
	char md_name[MAXPATHLEN];
617
	char *md_tmp;
618
#endif
590
619
591
	for (indx = 0; indx < argc; ++indx) {
620
	for (indx = 0; indx < argc; ++indx) {
592
		name = argv[indx];
621
		name = argv[indx];
Lines 594-605 Link Here
594
		len = strlen(name);
623
		len = strlen(name);
595
		while (len > 1 && name[len-1] == '/')
624
		while (len > 1 && name[len-1] == '/')
596
			name[--len] = '\0';
625
			name[--len] = '\0';
626
#if HAVE_COPYFILE
627
md_next:
628
		statbytes = 0;
629
		if (md_flag) {
630
		    fd = open(md_tmp, O_RDONLY, 0);
631
		    unlink(md_tmp);
632
		    free(md_tmp);
633
		    if (fd < 0)
634
			goto syserr;
635
		} else {
636
#endif
597
		if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0)
637
		if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0)
598
			goto syserr;
638
			goto syserr;
599
		if (strchr(name, '\n') != NULL) {
639
		if (strchr(name, '\n') != NULL) {
600
			strnvis(encname, name, sizeof(encname), VIS_NL);
640
			strnvis(encname, name, sizeof(encname), VIS_NL);
601
			name = encname;
641
			name = encname;
602
		}
642
		}
643
#if HAVE_COPYFILE
644
		}
645
#endif
603
		if (fstat(fd, &stb) < 0) {
646
		if (fstat(fd, &stb) < 0) {
604
syserr:			run_err("%s: %s", name, strerror(errno));
647
syserr:			run_err("%s: %s", name, strerror(errno));
605
			goto next;
648
			goto next;
Lines 688-693 Link Here
688
		else
731
		else
689
			run_err("%s: %s", name, strerror(haderr));
732
			run_err("%s: %s", name, strerror(haderr));
690
		(void) response();
733
		(void) response();
734
#ifdef HAVE_COPYFILE
735
		if (copy_xattr && md_flag == 0)
736
		{
737
		    if (!copyfile(name, NULL, 0,
738
			    COPYFILE_ACL | COPYFILE_XATTR | COPYFILE_CHECK))
739
			continue;
740
741
		    /*
742
		     * this file will hold the actual metadata
743
		     * to be transferred
744
		     */
745
		    md_tmp = strdup("/tmp/scp.md.XXXXXX");
746
		    md_tmp = mktemp(md_tmp);
747
748
		    if(copyfile(name, md_tmp, 0,
749
				COPYFILE_ACL | COPYFILE_XATTR | COPYFILE_PACK) == 0)
750
		    {
751
			/*
752
			 * this is the fake name to display
753
			 */
754
			snprintf(md_name, sizeof md_name, "%s/._%s", dirname(name), basename(name));
755
			name = md_name;
756
			md_flag = 1;
757
			if (verbose_mode)
758
			    fprintf(stderr, "copyfile(%s, %s, PACK)\n", name, md_tmp);
759
			goto md_next;
760
		    }
761
		} else
762
		    md_flag = 0;
763
#endif
691
	}
764
	}
692
}
765
}
693
766
Lines 836-841 Link Here
836
	if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
909
	if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode))
837
		targisdir = 1;
910
		targisdir = 1;
838
	for (first = 1;; first = 0) {
911
	for (first = 1;; first = 0) {
912
#if HAVE_COPYFILE
913
		char md_src[MAXPATHLEN];
914
		char md_dst[MAXPATHLEN];
915
#endif
839
		cp = buf;
916
		cp = buf;
840
		if (atomicio(read, remin, cp, 1) != 1)
917
		if (atomicio(read, remin, cp, 1) != 1)
841
			return;
918
			return;
Lines 969-974 Link Here
969
		}
1046
		}
970
		omode = mode;
1047
		omode = mode;
971
		mode |= S_IWRITE;
1048
		mode |= S_IWRITE;
1049
1050
#if HAVE_COPYFILE
1051
		if (copy_xattr && !strncmp(basename(curfile), "._", 2))
1052
		{
1053
			int mdfd;
1054
			if (targisdir)
1055
			{
1056
			    snprintf(md_src, sizeof md_src, "%s.XXXXXX", np);
1057
			    snprintf(md_dst, sizeof md_dst, "%s/%s",
1058
				    dirname(np), basename(np) + 2);
1059
			    if((mdfd = mkstemp(md_src)) < 0)
1060
				continue;
1061
			}
1062
			else
1063
			{
1064
			    snprintf(md_src, sizeof md_src, "%s/._%s.XXXXXX",
1065
				    dirname(np), basename(np));
1066
			    snprintf(md_dst, sizeof md_dst, "%s", np);
1067
			    if((mdfd = mkstemp(md_src)) < 0)
1068
				continue;
1069
			}
1070
			if (mdfd >= 0)
1071
				close(mdfd);
1072
			np = md_src;
1073
		}
1074
#endif
972
		if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) < 0) {
1075
		if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) < 0) {
973
bad:			run_err("%s: %s", np, strerror(errno));
1076
bad:			run_err("%s: %s", np, strerror(errno));
974
			continue;
1077
			continue;
Lines 1057-1062 Link Here
1057
			wrerrno = errno;
1160
			wrerrno = errno;
1058
		}
1161
		}
1059
		(void) response();
1162
		(void) response();
1163
#ifdef HAVE_COPYFILE
1164
		if (copy_xattr && strncmp(basename(np), "._", 2) == 0)
1165
		{
1166
			if (verbose_mode)
1167
			    fprintf(stderr, "copyfile(%s, %s, UNPACK)\n", md_src, md_dst);
1168
			if(!copyfile(md_src, md_dst, 0,
1169
			    COPYFILE_ACL | COPYFILE_XATTR | COPYFILE_UNPACK) < 0)
1170
			{
1171
			    snprintf(md_dst, sizeof md_dst, "%s/._%s",
1172
				    dirname(md_dst), basename(md_dst));
1173
			    rename(md_src, md_dst);
1174
			} else
1175
			    unlink(md_src);
1176
		} else
1177
#endif
1060
		if (setimes && wrerr == NO) {
1178
		if (setimes && wrerr == NO) {
1061
			setimes = 0;
1179
			setimes = 0;
1062
			if (utimes(np, tv) < 0) {
1180
			if (utimes(np, tv) < 0) {
Lines 1118-1124 Link Here
1118
usage(void)
1236
usage(void)
1119
{
1237
{
1120
	(void) fprintf(stderr,
1238
	(void) fprintf(stderr,
1239
#if HAVE_COPYFILE
1240
	    "usage: scp [-1246BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
1241
#else
1121
	    "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
1242
	    "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
1243
#endif
1122
	    "           [-l limit] [-o ssh_option] [-P port] [-S program]\n"
1244
	    "           [-l limit] [-o ssh_option] [-P port] [-S program]\n"
1123
	    "           [[user@]host1:]file1 ... [[user@]host2:]file2\n");
1245
	    "           [[user@]host1:]file1 ... [[user@]host2:]file2\n");
1124
	exit(1);
1246
	exit(1);

Return to bug 1409