Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cranspasswords
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Stan
Cranspasswords
Commits
15f817e8
Commit
15f817e8
authored
12 years ago
by
Daniel STAN
Browse files
Options
Downloads
Patches
Plain Diff
On utilise cat si mdp caché
parent
4db1d21f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cranspasswords.py
+26
-17
26 additions, 17 deletions
cranspasswords.py
with
26 additions
and
17 deletions
cranspasswords.py
+
26
−
17
View file @
15f817e8
...
...
@@ -9,8 +9,13 @@ import tempfile
import
os
import
atexit
import
argparse
import
re
import
config
## Password pattern in files:
PASS
=
re
.
compile
(
'
[
\t
]*pass(?:word)?[
\t
]*:[
\t
]*(.*)
\r
?
\n
?$
'
,
\
flags
=
re
.
IGNORECASE
)
######
## GPG Definitions
...
...
@@ -175,6 +180,8 @@ def put_password(name, roles, contents):
enc_pwd
=
encrypt
(
roles
,
contents
)
if
NROLES
!=
None
:
roles
=
NROLES
if
VERB
:
print
"
Pas de nouveaux rôles
"
if
enc_pwd
<>
None
:
return
put_file
(
name
,
roles
,
enc_pwd
)
else
:
...
...
@@ -201,7 +208,7 @@ def editor(texte):
return
texte
<>
ntexte
and
ntexte
or
None
def
show_files
():
proc
=
subprocess
.
Popen
(
"
less
"
,
stdin
=
subprocess
.
PIPE
,
shell
=
True
)
proc
=
subprocess
.
Popen
(
"
cat
"
,
stdin
=
subprocess
.
PIPE
,
shell
=
True
)
out
=
proc
.
stdin
out
.
write
(
"""
Liste des fichiers disponibles
\n
"""
)
my_roles
=
get_my_roles
()
...
...
@@ -248,28 +255,30 @@ def clipboard(texte):
def
show_file
(
fname
):
value
=
get_file
(
fname
)
if
value
==
False
:
print
"
Fichier introuvable
"
;
return
proc
=
subprocess
.
Popen
(
"
less
"
,
stdin
=
subprocess
.
PIPE
,
shell
=
True
)
out
=
proc
.
stdin
out
.
write
(
"
Fichier %s:
\n\n
"
%
fname
)
print
"
Fichier introuvable
"
return
(
sin
,
sout
)
=
gpg
(
'
decrypt
'
)
sin
.
write
(
value
[
'
contents
'
])
sin
.
close
()
if
CLIPBOARD
:
# Ça ne va pas plaire à tout le monde
texte
=
sout
.
read
()
lines
=
texte
.
split
(
'
\n
'
)
for
line
in
lines
:
if
line
.
startswith
(
'
pass:
'
):
out
.
write
(
clipboard
(
line
[
5
:].
strip
(
'
\t\r\n
'
))
+
'
\n
'
)
else
:
out
.
write
(
line
+
'
\n
'
)
else
:
# Si pas de presse papier, on fait passer ça dans un less
out
.
write
(
sout
.
read
())
texte
=
sout
.
read
()
ntexte
=
""
hidden
=
False
# Est-ce que le mot de passe a été caché ?
lines
=
texte
.
split
(
'
\n
'
)
for
line
in
lines
:
catchPass
=
PASS
.
match
(
line
)
if
catchPass
!=
None
and
CLIPBOARD
:
hidden
=
True
line
=
clipboard
(
catchPass
.
group
(
1
))
ntexte
+=
line
+
'
\n
'
showbin
=
"
cat
"
if
hidden
else
"
less
"
proc
=
subprocess
.
Popen
(
showbin
,
stdin
=
subprocess
.
PIPE
,
shell
=
True
)
out
=
proc
.
stdin
out
.
write
(
"
Fichier %s:
\n\n
"
%
fname
)
out
.
write
(
ntexte
)
out
.
write
(
"
-----
\n
"
)
out
.
write
(
"
Visible par: %s
\n
"
%
'
,
'
.
join
(
value
[
'
roles
'
]))
out
.
close
()
os
.
waitpid
(
proc
.
pid
,
0
)
os
.
waitpid
(
proc
.
pid
,
0
)
def
edit_file
(
fname
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment