Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Crans Passwords
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Nounous
Crans Passwords
Commits
51ef42ab
Commit
51ef42ab
authored
12 years ago
by
root
Browse files
Options
Downloads
Plain Diff
Merge remote branch 'dstan_crans/master'
parents
8a38cd94
15f817e8
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 @
51ef42ab
...
@@ -9,8 +9,13 @@ import tempfile
...
@@ -9,8 +9,13 @@ import tempfile
import
os
import
os
import
atexit
import
atexit
import
argparse
import
argparse
import
re
import
config
import
config
## Password pattern in files:
PASS
=
re
.
compile
(
'
[
\t
]*pass(?:word)?[
\t
]*:[
\t
]*(.*)
\r
?
\n
?$
'
,
\
flags
=
re
.
IGNORECASE
)
######
######
## GPG Definitions
## GPG Definitions
...
@@ -175,6 +180,8 @@ def put_password(name, roles, contents):
...
@@ -175,6 +180,8 @@ def put_password(name, roles, contents):
enc_pwd
=
encrypt
(
roles
,
contents
)
enc_pwd
=
encrypt
(
roles
,
contents
)
if
NROLES
!=
None
:
if
NROLES
!=
None
:
roles
=
NROLES
roles
=
NROLES
if
VERB
:
print
"
Pas de nouveaux rôles
"
if
enc_pwd
<>
None
:
if
enc_pwd
<>
None
:
return
put_file
(
name
,
roles
,
enc_pwd
)
return
put_file
(
name
,
roles
,
enc_pwd
)
else
:
else
:
...
@@ -201,7 +208,7 @@ def editor(texte):
...
@@ -201,7 +208,7 @@ def editor(texte):
return
texte
<>
ntexte
and
ntexte
or
None
return
texte
<>
ntexte
and
ntexte
or
None
def
show_files
():
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
=
proc
.
stdin
out
.
write
(
"""
Liste des fichiers disponibles
\n
"""
)
out
.
write
(
"""
Liste des fichiers disponibles
\n
"""
)
my_roles
=
get_my_roles
()
my_roles
=
get_my_roles
()
...
@@ -248,28 +255,30 @@ def clipboard(texte):
...
@@ -248,28 +255,30 @@ def clipboard(texte):
def
show_file
(
fname
):
def
show_file
(
fname
):
value
=
get_file
(
fname
)
value
=
get_file
(
fname
)
if
value
==
False
:
if
value
==
False
:
print
"
Fichier introuvable
"
;
return
print
"
Fichier introuvable
"
proc
=
subprocess
.
Popen
(
"
less
"
,
stdin
=
subprocess
.
PIPE
,
shell
=
True
)
return
out
=
proc
.
stdin
out
.
write
(
"
Fichier %s:
\n\n
"
%
fname
)
(
sin
,
sout
)
=
gpg
(
'
decrypt
'
)
(
sin
,
sout
)
=
gpg
(
'
decrypt
'
)
sin
.
write
(
value
[
'
contents
'
])
sin
.
write
(
value
[
'
contents
'
])
sin
.
close
()
sin
.
close
()
if
CLIPBOARD
:
# Ça ne va pas plaire à tout le monde
texte
=
sout
.
read
()
texte
=
sout
.
read
()
ntexte
=
""
lines
=
texte
.
split
(
'
\n
'
)
hidden
=
False
# Est-ce que le mot de passe a été caché ?
for
line
in
lines
:
lines
=
texte
.
split
(
'
\n
'
)
if
line
.
startswith
(
'
pass:
'
):
for
line
in
lines
:
out
.
write
(
clipboard
(
line
[
5
:].
strip
(
'
\t\r\n
'
))
+
'
\n
'
)
catchPass
=
PASS
.
match
(
line
)
else
:
if
catchPass
!=
None
and
CLIPBOARD
:
out
.
write
(
line
+
'
\n
'
)
hidden
=
True
else
:
# Si pas de presse papier, on fait passer ça dans un less
line
=
clipboard
(
catchPass
.
group
(
1
))
out
.
write
(
sout
.
read
())
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
(
"
-----
\n
"
)
out
.
write
(
"
Visible par: %s
\n
"
%
'
,
'
.
join
(
value
[
'
roles
'
]))
out
.
write
(
"
Visible par: %s
\n
"
%
'
,
'
.
join
(
value
[
'
roles
'
]))
out
.
close
()
out
.
close
()
os
.
waitpid
(
proc
.
pid
,
0
)
os
.
waitpid
(
proc
.
pid
,
0
)
def
edit_file
(
fname
):
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