diff options
-rw-r--r-- | Makefile.in | 10 | ||||
-rw-r--r-- | scp-common.c | 98 | ||||
-rw-r--r-- | scp-common.h | 64 |
3 files changed, 167 insertions, 5 deletions
diff --git a/Makefile.in b/Makefile.in index f0b2f6937..4b545e4b1 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.168 2001/04/16 00:41:46 djm Exp $ | 1 | # $Id: Makefile.in,v 1.169 2001/04/16 08:36:39 djm Exp $ |
2 | 2 | ||
3 | prefix=@prefix@ | 3 | prefix=@prefix@ |
4 | exec_prefix=@exec_prefix@ | 4 | exec_prefix=@exec_prefix@ |
@@ -94,8 +94,8 @@ ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) | |||
94 | sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) | 94 | sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) |
95 | $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) | 95 | $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) |
96 | 96 | ||
97 | scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o | 97 | scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o scp-common.o |
98 | $(LD) -o $@ scp.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) | 98 | $(LD) -o $@ scp.o scp-common.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) |
99 | 99 | ||
100 | ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o | 100 | ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o |
101 | $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) | 101 | $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) |
@@ -112,8 +112,8 @@ ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o | |||
112 | sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o | 112 | sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o |
113 | $(LD) -o $@ sftp-server.o sftp-common.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) | 113 | $(LD) -o $@ sftp-server.o sftp-common.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) |
114 | 114 | ||
115 | sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-int.o sftp-common.o sftp-glob.o | 115 | sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-int.o sftp-common.o sftp-glob.o scp-common.o |
116 | $(LD) -o $@ sftp.o sftp-client.o sftp-common.o sftp-int.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) | 116 | $(LD) -o $@ sftp.o sftp-client.o sftp-common.o sftp-int.o sftp-glob.o scp-common.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) |
117 | 117 | ||
118 | # test driver for the loginrec code - not built by default | 118 | # test driver for the loginrec code - not built by default |
119 | logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o | 119 | logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o |
diff --git a/scp-common.c b/scp-common.c new file mode 100644 index 000000000..7e5f09c74 --- /dev/null +++ b/scp-common.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1999 Theo de Raadt. All rights reserved. | ||
3 | * Copyright (c) 1999 Aaron Campbell. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | */ | ||
25 | |||
26 | /* | ||
27 | * Parts from: | ||
28 | * | ||
29 | * Copyright (c) 1983, 1990, 1992, 1993, 1995 | ||
30 | * The Regents of the University of California. All rights reserved. | ||
31 | * | ||
32 | * Redistribution and use in source and binary forms, with or without | ||
33 | * modification, are permitted provided that the following conditions | ||
34 | * are met: | ||
35 | * 1. Redistributions of source code must retain the above copyright | ||
36 | * notice, this list of conditions and the following disclaimer. | ||
37 | * 2. Redistributions in binary form must reproduce the above copyright | ||
38 | * notice, this list of conditions and the following disclaimer in the | ||
39 | * documentation and/or other materials provided with the distribution. | ||
40 | * 3. All advertising materials mentioning features or use of this software | ||
41 | * must display the following acknowledgement: | ||
42 | * This product includes software developed by the University of | ||
43 | * California, Berkeley and its contributors. | ||
44 | * 4. Neither the name of the University nor the names of its contributors | ||
45 | * may be used to endorse or promote products derived from this software | ||
46 | * without specific prior written permission. | ||
47 | * | ||
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
58 | * SUCH DAMAGE. | ||
59 | * | ||
60 | */ | ||
61 | |||
62 | #include "includes.h" | ||
63 | RCSID("$OpenBSD: scp-common.c,v 1.1 2001/04/16 02:31:43 mouring Exp $"); | ||
64 | |||
65 | char * | ||
66 | cleanhostname(host) | ||
67 | char *host; | ||
68 | { | ||
69 | if (*host == '[' && host[strlen(host) - 1] == ']') { | ||
70 | host[strlen(host) - 1] = '\0'; | ||
71 | return (host + 1); | ||
72 | } else | ||
73 | return host; | ||
74 | } | ||
75 | |||
76 | char * | ||
77 | colon(cp) | ||
78 | char *cp; | ||
79 | { | ||
80 | int flag = 0; | ||
81 | |||
82 | if (*cp == ':') /* Leading colon is part of file name. */ | ||
83 | return (0); | ||
84 | if (*cp == '[') | ||
85 | flag = 1; | ||
86 | |||
87 | for (; *cp; ++cp) { | ||
88 | if (*cp == '@' && *(cp+1) == '[') | ||
89 | flag = 1; | ||
90 | if (*cp == ']' && *(cp+1) == ':' && flag) | ||
91 | return (cp+1); | ||
92 | if (*cp == ':' && !flag) | ||
93 | return (cp); | ||
94 | if (*cp == '/') | ||
95 | return (0); | ||
96 | } | ||
97 | return (0); | ||
98 | } | ||
diff --git a/scp-common.h b/scp-common.h new file mode 100644 index 000000000..e0ab6ec32 --- /dev/null +++ b/scp-common.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* $OpenBSD: scp-common.h,v 1.1 2001/04/16 02:31:43 mouring Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 1999 Theo de Raadt. All rights reserved. | ||
4 | * Copyright (c) 1999 Aaron Campbell. All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | /* | ||
28 | * Parts from: | ||
29 | * | ||
30 | * Copyright (c) 1983, 1990, 1992, 1993, 1995 | ||
31 | * The Regents of the University of California. All rights reserved. | ||
32 | * | ||
33 | * Redistribution and use in source and binary forms, with or without | ||
34 | * modification, are permitted provided that the following conditions | ||
35 | * are met: | ||
36 | * 1. Redistributions of source code must retain the above copyright | ||
37 | * notice, this list of conditions and the following disclaimer. | ||
38 | * 2. Redistributions in binary form must reproduce the above copyright | ||
39 | * notice, this list of conditions and the following disclaimer in the | ||
40 | * documentation and/or other materials provided with the distribution. | ||
41 | * 3. All advertising materials mentioning features or use of this software | ||
42 | * must display the following acknowledgement: | ||
43 | * This product includes software developed by the University of | ||
44 | * California, Berkeley and its contributors. | ||
45 | * 4. Neither the name of the University nor the names of its contributors | ||
46 | * may be used to endorse or promote products derived from this software | ||
47 | * without specific prior written permission. | ||
48 | * | ||
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
59 | * SUCH DAMAGE. | ||
60 | * | ||
61 | */ | ||
62 | |||
63 | char *cleanhostname(char *host); | ||
64 | char *colon(char *cp); | ||