Merge lp:~kirkland/pastebinit/pbput into lp:pastebinit

Proposed by Rolf Leggewie
Status: Merged
Merged at revision: 134
Proposed branch: lp:~kirkland/pastebinit/pbput
Merge into: lp:pastebinit
Diff against target: 159 lines (+141/-0)
2 files modified
pbput (+74/-0)
pbput.1 (+67/-0)
To merge this branch: bzr merge lp:~kirkland/pastebinit/pbput
Reviewer Review Type Date Requested Status
Stéphane Graber Pending
Review via email: mp+76913@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added symlink 'pbget'
2=== target is u'pbput'
3=== added symlink 'pbget.1'
4=== target is u'pbput.1'
5=== added file 'pbput'
6--- pbput 1970-01-01 00:00:00 +0000
7+++ pbput 2011-09-25 20:43:25 +0000
8@@ -0,0 +1,74 @@
9+#!/bin/sh
10+#
11+# pbput, pbputs, pbget - put and get binary files to/from pastebin.com
12+# Copyright (C) 2010 Dustin Kirkland <dustin.kirkland@gmail.com>
13+#
14+# Authors: Dustin Kirkland <dustin.kirkland@gmail.com>
15+#
16+# This program is free software; you can redistribute it and/or modify
17+# it under the terms of the GNU General Public License as published by
18+# the Free Software Foundation; either version 2 of the License, or
19+# (at your option) any later version.
20+#
21+# This program is distributed in the hope that it will be useful,
22+# but WITHOUT ANY WARRANTY; without even the implied warranty of
23+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+# GNU General Public License for more details.
25+#
26+# You should have received a copy of the GNU General Public License along
27+# with this program; if not, write to the Free Software Foundation, Inc.,
28+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29+
30+PROG=$(basename $0)
31+URL="http://pastebin.com"
32+TEMPLATE="$PROG.XXXXXXXXXX"
33+[ -d "$TMPDIR" ] && TEMPLATE="$TMPDIR/$TEMPLATE" || TEMPLATE="/tmp/$TEMPLATE"
34+
35+# Create a secure tempfiles
36+TEMP=$(mktemp $TEMPLATE)
37+TEMP2=$(mktemp $TEMPLATE)
38+trap "rm -f $TEMP $TEMP2 2>/dev/null || true" EXIT HUP INT QUIT TERM
39+
40+case "$PROG" in
41+ pbget)
42+ url=$(echo "$1" | sed -e "s:.com/:.com/download.php?i=:")
43+ wget -q -O- "$url" | base64 -d | lzma -d > "$TEMP"
44+ # Support secure uploads
45+ if gpg -d "$TEMP" >"$TEMP2" 2>/dev/null; then
46+ # Upload was encrypted
47+ mv -f "$TEMP2" "$TEMP"
48+ fi
49+ if LC=C file "$TEMP" | grep -qs "^$TEMP: POSIX tar archive"; then
50+ # Download is a tarball; unpack safely
51+ [ -d "$2" ] && DIR="$2" || DIR=$(mktemp -d $TEMPLATE)
52+ tar -C "$DIR" -xvf "$TEMP" 2>/dev/null || cat "$TEMP"
53+ echo "INFO: Output is in [$DIR]"
54+ else
55+ # Upload came from stdin, so display on stdout
56+ cat "$TEMP"
57+ fi
58+ ;;
59+ pbput|pbputs)
60+ if [ -r "$1" ]; then
61+ # Read file from argument
62+ tar cf "$TEMP" "$1"
63+ # Second argument indicates a target user in the gpg keyring
64+ [ -z "$2" ] && GPG_OPTS="-c" || GPG_OPTS="-s -e -r $2"
65+ else
66+ # Read from standard in
67+ cat /dev/stdin > "$TEMP"
68+ # Argument indicates a target user in the gpg keyring
69+ [ -z "$1" ] && GPG_OPTS="-c" || GPG_OPTS="-s -e -r $1"
70+ fi
71+ if [ "$PROG" = "pbputs" ]; then
72+ mv -f "$TEMP" "$TEMP".in
73+ cat "$TEMP".in | gpg $GPG_OPTS > "$TEMP"
74+ rm -f "$TEMP".in
75+ fi
76+ lzma -9 -f -c "$TEMP" | base64 | pastebinit -b "$URL"
77+ ;;
78+ *)
79+ echo "ERROR" 1>&2
80+ exit 1
81+ ;;
82+esac
83
84=== added file 'pbput.1'
85--- pbput.1 1970-01-01 00:00:00 +0000
86+++ pbput.1 2011-09-25 20:43:25 +0000
87@@ -0,0 +1,67 @@
88+.TH pbput 1 "6 Oct 2010" bikeshed "bikeshed"
89+.SH NAME
90+pbput - compress and encode arbitrary files to pastebin.com
91+
92+pbputs - compress, encrypt, encode arbitrary files to pastebin.com
93+
94+pbget - decode and decompress arbitrary files from pastebin.com
95+
96+.SH SYNOPSIS
97+\fBpbput\fP [FILENAME]
98+
99+cat foo | \fBpbput\fP
100+
101+\fBpbputs\fP [FILENAME] [GPG_USER]
102+
103+cat foo | \fBpbputs [GPG_USER]\fP
104+
105+\fBpbget\fP URL [DIRECTORY]
106+
107+.SH DESCRIPTION
108+\fBpbput\fP is a program that can upload text files, binary files or entire directory structures to a pastebin, such as pastebin.com.
109+
110+\fBpbget\fP is a program that be used to retrieve content uploaded to a pastebin by \fBpbput\fP.
111+
112+\fBpbputs\fP operates exactly like \fBpbput\fP, except it encrypts the data. An optional GPG_USER argument is allowed, which will sign and encrypt the data to the target user in one's keyring (which could be oneself!). Otherwise, the user is prompted for a symmetric passphrase for encrypting the content with \fBgpg\fP(1) before uploading. \fBpbget\fP will automatically prompt the receiving user for the pre-shared passphrase.
113+
114+\fBpbput\fP and \fBpbputs\fP can take its input either on STDIN, or as a FILENAME argument.
115+ - If STDIN is used, then the receiving user's \fBpbget\fP will simply paste the input on STDOUT.
116+ - If a FILENAME or DIRECTORY is passed as an argument, then it is first archived using \fBtar\fP(1) to preserve the file and directory attributes
117+
118+\fBpbget\fP takes a URL as its first, mandatory argument. Optionally, it takes a DIRECTORY as a second parameter. If the incoming data is in fact a file or file structure in a \fBtar\fP(1) archive, then that data will be extracted in the specified DIRECTORY. If no DIRECTORY is specified, then a temporary directory is created using \fBmktemp\fP(1).
119+
120+In any case the uploaded/downloaded data is optionally \fBtar\fP(1) archived, always \fBlzma\fP(1) compressed, optionally \fBgpg\fP(1) encrypted, and always \fBbase64\fP(1) encoded. \fIhttp://pastebin.com\fP is used by default.
121+
122+.SH EXAMPLES
123+ $ pbput /sbin/init
124+ http://pastebin.com/BstNzasK
125+ $ pbget http://pastebin.com/BstNzasK
126+ sbin/init
127+ INFO: Output is in [/tmp/pbget.bG67DwY6Zl]
128+
129+ $ cat /etc/lsb-release | pbput
130+ http://pastebin.com/p43gJv6Z
131+ $ pbget http://pastebin.com/p43gJv6Z
132+ DISTRIB_ID=Ubuntu
133+ DISTRIB_RELEASE=11.04
134+ DISTRIB_CODENAME=natty
135+ DISTRIB_DESCRIPTION="Ubuntu 11.04"
136+
137+ $ pbputs /etc/shadow
138+ Enter passphrase:
139+ http://pastebin.com/t2ZaCYr3
140+ $ pbget http://pastebin.com/t2ZaCYr3
141+ Enter passphrase:
142+ root:09cc6d2d9d63371a425076e217f77698:15096:0:99999:7:::
143+ daemon:*:15089:0:99999:7:::
144+ bin:*:15089:0:99999:7:::
145+ sys:*:15089:0:99999:7:::
146+ ....
147+
148+.SH SEE ALSO
149+\fBpastebinit\fP(1)\fP, \fBlzma\fP(1), \fBbase64\fP(1), \fBtar\fP(1), \fBgpg\fP(1), \fBmktemp\fP(1)
150+
151+.SH AUTHOR
152+This manpage and the utility was written by Dustin Kirkland <kirkland@ubuntu.com> for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or later published by the Free Software Foundation.
153+
154+On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL, or on the web at \fIhttp://www.gnu.org/licenses/gpl.txt\fP.
155
156=== added symlink 'pbputs'
157=== target is u'pbput'
158=== added symlink 'pbputs.1'
159=== target is u'pbput.1'

Subscribers

People subscribed via source and target branches