Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
f704703e
Commit
f704703e
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Reformat the files in bin/.
parent
0528937a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/importPdoMetadata.php
+17
-17
17 additions, 17 deletions
bin/importPdoMetadata.php
bin/initMDSPdo.php
+13
-13
13 additions, 13 deletions
bin/initMDSPdo.php
bin/memcacheSync.php
+118
-116
118 additions, 116 deletions
bin/memcacheSync.php
bin/pwgen.php
+15
-15
15 additions, 15 deletions
bin/pwgen.php
with
163 additions
and
161 deletions
bin/importPdoMetadata.php
+
17
−
17
View file @
f704703e
...
@@ -2,27 +2,27 @@
...
@@ -2,27 +2,27 @@
<?php
<?php
$baseDir
=
dirname
(
dirname
(
__FILE__
));
$baseDir
=
dirname
(
dirname
(
__FILE__
));
require_once
$baseDir
.
DIRECTORY_SEPARATOR
.
'lib'
.
DIRECTORY_SEPARATOR
.
'_autoload.php'
;
require_once
$baseDir
.
DIRECTORY_SEPARATOR
.
'lib'
.
DIRECTORY_SEPARATOR
.
'_autoload.php'
;
require_once
SimpleSAML\Utils\Config
::
getConfigDir
()
.
DIRECTORY_SEPARATOR
.
'config.php'
;
require_once
SimpleSAML\Utils\Config
::
getConfigDir
()
.
DIRECTORY_SEPARATOR
.
'config.php'
;
# Iterate through configured metadata sources and ensure
# Iterate through configured metadata sources and ensure
# that a PDO source exists.
# that a PDO source exists.
foreach
(
$config
[
'metadata.sources'
]
as
$s
)
{
foreach
(
$config
[
'metadata.sources'
]
as
$s
)
{
# If pdo is configured, create the new handler and add in the metadata sets.
# If pdo is configured, create the new handler and add in the metadata sets.
if
(
$s
[
'type'
]
===
"pdo"
)
{
if
(
$s
[
'type'
]
===
"pdo"
)
{
$mdshp
=
new
SimpleSAML_Metadata_MetaDataStorageHandlerPdo
(
$s
);
$mdshp
=
new
SimpleSAML_Metadata_MetaDataStorageHandlerPdo
(
$s
);
$mdshp
->
initDatabase
();
$mdshp
->
initDatabase
();
foreach
(
glob
(
"metadata/*.php"
)
as
$filename
)
{
foreach
(
glob
(
"metadata/*.php"
)
as
$filename
)
{
$metadata
=
array
();
$metadata
=
array
();
require_once
$filename
;
require_once
$filename
;
$set
=
basename
(
$filename
,
".php"
);
$set
=
basename
(
$filename
,
".php"
);
echo
"importing set '
$set
'..."
.
PHP_EOL
;
echo
"importing set '
$set
'..."
.
PHP_EOL
;
foreach
(
$metadata
as
$k
=>
$v
)
{
foreach
(
$metadata
as
$k
=>
$v
)
{
echo
"
\t
$k
"
.
PHP_EOL
;
echo
"
\t
$k
"
.
PHP_EOL
;
$mdshp
->
addEntry
(
$k
,
$set
,
$v
);
$mdshp
->
addEntry
(
$k
,
$set
,
$v
);
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
bin/initMDSPdo.php
+
13
−
13
View file @
f704703e
...
@@ -5,23 +5,23 @@
...
@@ -5,23 +5,23 @@
$baseDir
=
dirname
(
dirname
(
__FILE__
));
$baseDir
=
dirname
(
dirname
(
__FILE__
));
// Add library autoloader and configuration
// Add library autoloader and configuration
require_once
$baseDir
.
DIRECTORY_SEPARATOR
.
'lib'
.
DIRECTORY_SEPARATOR
.
'_autoload.php'
;
require_once
$baseDir
.
DIRECTORY_SEPARATOR
.
'lib'
.
DIRECTORY_SEPARATOR
.
'_autoload.php'
;
require_once
SimpleSAML\Utils\Config
::
getConfigDir
()
.
DIRECTORY_SEPARATOR
.
'config.php'
;
require_once
SimpleSAML\Utils\Config
::
getConfigDir
()
.
DIRECTORY_SEPARATOR
.
'config.php'
;
echo
"Initializing Metadata Database..."
.
PHP_EOL
;
echo
"Initializing Metadata Database..."
.
PHP_EOL
;
# Iterate through configured metadata sources and ensure
# Iterate through configured metadata sources and ensure
# that a PDO source exists.
# that a PDO source exists.
foreach
(
$config
[
'metadata.sources'
]
as
$source
)
{
foreach
(
$config
[
'metadata.sources'
]
as
$source
)
{
# If pdo is configured, create the new handler and initialize the DB.
# If pdo is configured, create the new handler and initialize the DB.
if
(
$source
[
'type'
]
===
"pdo"
)
{
if
(
$source
[
'type'
]
===
"pdo"
)
{
$metadataStorageHandler
=
new
SimpleSAML_Metadata_MetaDataStorageHandlerPdo
(
$source
);
$metadataStorageHandler
=
new
SimpleSAML_Metadata_MetaDataStorageHandlerPdo
(
$source
);
$result
=
$metadataStorageHandler
->
initDatabase
();
$result
=
$metadataStorageHandler
->
initDatabase
();
if
(
$result
===
false
)
{
if
(
$result
===
false
)
{
echo
"Failed to intialize metadata database."
.
PHP_EOL
;
echo
"Failed to in
i
tialize metadata database."
.
PHP_EOL
;
}
else
{
}
else
{
echo
"Successfully initialized metadata database."
.
PHP_EOL
;
echo
"Successfully initialized metadata database."
.
PHP_EOL
;
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
bin/memcacheSync.php
+
118
−
116
View file @
f704703e
...
@@ -3,25 +3,25 @@
...
@@ -3,25 +3,25 @@
// Check that the memcache library is enabled
// Check that the memcache library is enabled
if
(
!
class_exists
(
'Memcache'
))
{
if
(
!
class_exists
(
'Memcache'
))
{
echo
(
"Error: the memcache library appears to be unavailable.
\n
"
);
echo
(
"Error: the memcache library appears to be unavailable.
\n
"
);
echo
(
"
\n
"
);
echo
(
"
\n
"
);
echo
(
"This is most likely because PHP doesn't load it for the command line
\n
"
);
echo
(
"This is most likely because PHP doesn't load it for the command line
\n
"
);
echo
(
"version. You probably need to enable it somehow.
\n
"
);
echo
(
"version. You probably need to enable it somehow.
\n
"
);
echo
(
"
\n
"
);
echo
(
"
\n
"
);
if
(
is_dir
(
'/etc/php5/cli/conf.d'
))
{
if
(
is_dir
(
'/etc/php5/cli/conf.d'
))
{
echo
(
"It is possible that running the following command as root will fix it:
\n
"
);
echo
(
"It is possible that running the following command as root will fix it:
\n
"
);
echo
(
" echo 'extension=memcache.so' >/etc/php5/cli/conf.d/memcache.ini
\n
"
);
echo
(
" echo 'extension=memcache.so' >/etc/php5/cli/conf.d/memcache.ini
\n
"
);
}
}
exit
(
1
);
exit
(
1
);
}
}
// This is the base directory of the SimpleSAMLphp installation
// This is the base directory of the SimpleSAMLphp installation
$baseDir
=
dirname
(
dirname
(
__FILE__
));
$baseDir
=
dirname
(
dirname
(
__FILE__
));
// Add library autoloader
// Add library autoloader
require_once
(
$baseDir
.
'/lib/_autoload.php'
);
require_once
(
$baseDir
.
'/lib/_autoload.php'
);
// Initialize the configuration
// Initialize the configuration
$configdir
=
SimpleSAML\Utils\Config
::
getConfigDir
();
$configdir
=
SimpleSAML\Utils\Config
::
getConfigDir
();
...
@@ -35,129 +35,131 @@ $warnBigSlab = 0;
...
@@ -35,129 +35,131 @@ $warnBigSlab = 0;
$stats
=
SimpleSAML_Memcache
::
getRawStats
();
$stats
=
SimpleSAML_Memcache
::
getRawStats
();
$keys
=
array
();
$keys
=
array
();
foreach
(
$stats
as
$group
)
{
foreach
(
$stats
as
$group
)
{
foreach
(
$group
as
$server
=>
$state
)
{
foreach
(
$group
as
$server
=>
$state
)
{
if
(
$state
===
FALSE
)
{
if
(
$state
===
false
)
{
echo
(
"WARNING: Server "
.
$server
.
" is down.
\n
"
);
echo
(
"WARNING: Server "
.
$server
.
" is down.
\n
"
);
$warnServerDown
++
;
$warnServerDown
++
;
continue
;
continue
;
}
}
$items
=
$state
[
'curr_items'
];
$items
=
$state
[
'curr_items'
];
echo
(
"Server "
.
$server
.
" has "
.
$items
.
" items.
\n
"
);
echo
(
"Server "
.
$server
.
" has "
.
$items
.
" items.
\n
"
);
$serverKeys
=
getServerKeys
(
$server
);
$serverKeys
=
getServerKeys
(
$server
);
$keys
=
array_merge
(
$keys
,
$serverKeys
);
$keys
=
array_merge
(
$keys
,
$serverKeys
);
}
}
}
}
echo
(
"Total number of keys: "
.
count
(
$keys
)
.
"
\n
"
);
echo
(
"Total number of keys: "
.
count
(
$keys
)
.
"
\n
"
);
$keys
=
array_unique
(
$keys
);
$keys
=
array_unique
(
$keys
);
echo
(
"Total number of unique keys: "
.
count
(
$keys
)
.
"
\n
"
);
echo
(
"Total number of unique keys: "
.
count
(
$keys
)
.
"
\n
"
);
echo
(
"Starting synchronization.
\n
"
);
echo
(
"Starting synchronization.
\n
"
);
$skipped
=
0
;
$skipped
=
0
;
$sync
=
0
;
$sync
=
0
;
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
$res
=
SimpleSAML_Memcache
::
get
(
$key
);
$res
=
SimpleSAML_Memcache
::
get
(
$key
);
if
(
$res
===
NULL
)
{
if
(
$res
===
null
)
{
$skipped
+=
1
;
$skipped
+=
1
;
}
else
{
}
else
{
$sync
+=
1
;
$sync
+=
1
;
}
}
}
}
echo
(
"Synchronization done.
\n
"
);
echo
(
"Synchronization done.
\n
"
);
echo
(
$sync
.
" keys in sync.
\n
"
);
echo
(
$sync
.
" keys in sync.
\n
"
);
if
(
$skipped
>
0
)
{
if
(
$skipped
>
0
)
{
echo
(
$skipped
.
" keys skipped.
\n
"
);
echo
(
$skipped
.
" keys skipped.
\n
"
);
echo
(
"Keys are skipped because they are either expired, or are of a type unknown
\n
"
);
echo
(
"Keys are skipped because they are either expired, or are of a type unknown
\n
"
);
echo
(
"to SimpleSAMLphp.
\n
"
);
echo
(
"to SimpleSAMLphp.
\n
"
);
}
}
if
(
$warnServerDown
>
0
)
{
if
(
$warnServerDown
>
0
)
{
echo
(
"WARNING: "
.
$warnServerDown
.
" server(s) down. Not all servers are synchronized.
\n
"
);
echo
(
"WARNING: "
.
$warnServerDown
.
" server(s) down. Not all servers are synchronized.
\n
"
);
}
}
if
(
$warnBigSlab
>
0
)
{
if
(
$warnBigSlab
>
0
)
{
echo
(
"WARNING: "
.
$warnBigSlab
.
" slab(s) may have contained more keys than we were told about.
\n
"
);
echo
(
"WARNING: "
.
$warnBigSlab
.
" slab(s) may have contained more keys than we were told about.
\n
"
);
}
}
/**
/**
* Fetch all keys available in an server.
* Fetch all keys available in an server.
*
*
* @param $server The server, as a string with <hostname>:<port>.
* @param string $server The server, as a string with <hostname>:<port>.
* @return An array with all the keys available on the server.
*
* @return array An array with all the keys available on the server.
*/
*/
function
getServerKeys
(
$server
)
{
function
getServerKeys
(
$server
)
$server
=
explode
(
':'
,
$server
);
{
$host
=
$server
[
0
];
$server
=
explode
(
':'
,
$server
);
$port
=
(
int
)
$server
[
1
];
$host
=
$server
[
0
];
$port
=
(
int
)
$server
[
1
];
echo
(
"Connecting to: "
.
$host
.
":"
.
$port
.
"
\n
"
);
$socket
=
fsockopen
(
$host
,
$port
);
echo
(
"Connecting to: "
.
$host
.
":"
.
$port
.
"
\n
"
);
echo
(
"Connected. Finding keys.
\n
"
);
$socket
=
fsockopen
(
$host
,
$port
);
echo
(
"Connected. Finding keys.
\n
"
);
if
(
fwrite
(
$socket
,
"stats slabs
\r\n
"
)
===
FALSE
)
{
echo
(
"Error requesting slab dump from server.
\n
"
);
if
(
fwrite
(
$socket
,
"stats slabs
\r\n
"
)
===
false
)
{
exit
(
1
);
echo
(
"Error requesting slab dump from server.
\n
"
);
}
exit
(
1
);
}
// Read list of slabs
$slabs
=
array
();
// Read list of slabs
while
(
(
$line
=
fgets
(
$socket
))
!==
FALSE
)
{
$slabs
=
array
();
$line
=
rtrim
(
$line
);
while
((
$line
=
fgets
(
$socket
))
!==
false
)
{
if
(
$line
===
'END'
)
{
$line
=
rtrim
(
$line
);
break
;
if
(
$line
===
'END'
)
{
}
break
;
}
if
(
preg_match
(
'/^STAT (\d+):/'
,
$line
,
$matches
))
{
$slab
=
(
int
)
$matches
[
1
];
if
(
preg_match
(
'/^STAT (\d+):/'
,
$line
,
$matches
))
{
if
(
!
in_array
(
$slab
,
$slabs
,
TRUE
))
{
$slab
=
(
int
)
$matches
[
1
];
$slabs
[]
=
$slab
;
if
(
!
in_array
(
$slab
,
$slabs
,
true
))
{
}
$slabs
[]
=
$slab
;
}
}
}
}
}
// Dump keys in slabs
$keys
=
array
();
// Dump keys in slabs
foreach
(
$slabs
as
$slab
)
{
$keys
=
array
();
foreach
(
$slabs
as
$slab
)
{
if
(
fwrite
(
$socket
,
"stats cachedump "
.
$slab
.
" 1000000
\r\n
"
)
===
FALSE
)
{
echo
(
"Error requesting cache dump from server.
\n
"
);
if
(
fwrite
(
$socket
,
"stats cachedump "
.
$slab
.
" 1000000
\r\n
"
)
===
false
)
{
exit
(
1
);
echo
(
"Error requesting cache dump from server.
\n
"
);
}
exit
(
1
);
}
/* We keep track of the result size, to be able to warn the user if it is
* so big that keys may have been lost.
/* We keep track of the result size, to be able to warn the user if it is
*/
* so big that keys may have been lost.
$resultSize
=
0
;
*/
$resultSize
=
0
;
while
(
(
$line
=
fgets
(
$socket
))
!==
FALSE
)
{
$resultSize
+=
strlen
(
$line
);
while
((
$line
=
fgets
(
$socket
))
!==
false
)
{
$resultSize
+=
strlen
(
$line
);
$line
=
rtrim
(
$line
);
if
(
$line
===
'END'
)
{
$line
=
rtrim
(
$line
);
break
;
if
(
$line
===
'END'
)
{
}
break
;
}
if
(
preg_match
(
'/^ITEM (.*) \[\d+ b; \d+ s\]/'
,
$line
,
$matches
))
{
$keys
[]
=
$matches
[
1
];
if
(
preg_match
(
'/^ITEM (.*) \[\d+ b; \d+ s\]/'
,
$line
,
$matches
))
{
}
else
{
$keys
[]
=
$matches
[
1
];
echo
(
"Unknown result from cache dump: "
.
$line
.
"
\n
"
);
}
else
{
}
echo
(
"Unknown result from cache dump: "
.
$line
.
"
\n
"
);
}
}
if
(
$resultSize
>
1900000
||
count
(
$keys
)
>=
1000000
)
{
}
echo
(
"WARNING: Slab "
.
$slab
.
" on server "
.
$host
.
":"
.
$port
.
if
(
$resultSize
>
1900000
||
count
(
$keys
)
>=
1000000
)
{
" may have contained more keys than we were told about.
\n
"
);
echo
(
"WARNING: Slab "
.
$slab
.
" on server "
.
$host
.
":"
.
$port
.
$GLOBALS
[
'warnBigSlab'
]
+=
1
;
" may have contained more keys than we were told about.
\n
"
);
}
$GLOBALS
[
'warnBigSlab'
]
+=
1
;
}
}
}
echo
(
"Found "
.
count
(
$keys
)
.
" key(s).
\n
"
);
fclose
(
$socket
);
echo
(
"Found "
.
count
(
$keys
)
.
" key(s).
\n
"
);
fclose
(
$socket
);
return
$keys
;
return
$keys
;
}
}
This diff is collapsed.
Click to expand it.
bin/pwgen.php
+
15
−
15
View file @
f704703e
...
@@ -10,38 +10,38 @@
...
@@ -10,38 +10,38 @@
$baseDir
=
dirname
(
dirname
(
__FILE__
));
$baseDir
=
dirname
(
dirname
(
__FILE__
));
// Add library autoloader
// Add library autoloader
require_once
(
$baseDir
.
'/lib/_autoload.php'
);
require_once
(
$baseDir
.
'/lib/_autoload.php'
);
echo
"Enter password: "
;
echo
"Enter password: "
;
$password
=
trim
(
fgets
(
STDIN
));
$password
=
trim
(
fgets
(
STDIN
));
if
(
empty
(
$password
))
{
if
(
empty
(
$password
))
{
echo
"Need at least one character for a password
\n
"
;
echo
"Need at least one character for a password
\n
"
;
exit
(
1
);
exit
(
1
);
}
}
$table
=
''
;
$table
=
''
;
foreach
(
array_chunk
(
hash_algos
(),
6
)
as
$chunk
)
{
foreach
(
array_chunk
(
hash_algos
(),
6
)
as
$chunk
)
{
foreach
(
$chunk
as
$algo
)
{
foreach
(
$chunk
as
$algo
)
{
$table
.
=
sprintf
(
'%-13s'
,
$algo
);
$table
.
=
sprintf
(
'%-13s'
,
$algo
);
}
}
$table
.
=
"
\n
"
;
$table
.
=
"
\n
"
;
}
}
echo
"The following hashing algorithms are available:
\n
"
.
$table
.
"
\n
"
;
echo
"The following hashing algorithms are available:
\n
"
.
$table
.
"
\n
"
;
echo
"Which one do you want? [sha256] "
;
echo
"Which one do you want? [sha256] "
;
$algo
=
trim
(
fgets
(
STDIN
));
$algo
=
trim
(
fgets
(
STDIN
));
if
(
empty
(
$algo
))
{
if
(
empty
(
$algo
))
{
$algo
=
'sha256'
;
$algo
=
'sha256'
;
}
}
if
(
!
in_array
(
strtolower
(
$algo
),
hash_algos
()))
{
if
(
!
in_array
(
strtolower
(
$algo
),
hash_algos
()))
{
echo
"Hashing algorithm '
$algo
' is not supported
\n
"
;
echo
"Hashing algorithm '
$algo
' is not supported
\n
"
;
exit
(
1
);
exit
(
1
);
}
}
echo
"Do you want to use a salt? (yes/no) [yes] "
;
echo
"Do you want to use a salt? (yes/no) [yes] "
;
$s
=
(
trim
(
fgets
(
STDIN
))
==
'no'
)
?
''
:
'S'
;
$s
=
(
trim
(
fgets
(
STDIN
))
==
'no'
)
?
''
:
'S'
;
echo
"
\n
"
.
SimpleSAML\Utils\Crypto
::
pwHash
(
$password
,
strtoupper
(
$s
.
$algo
)
)
.
"
\n\n
"
;
echo
"
\n
"
.
SimpleSAML\Utils\Crypto
::
pwHash
(
$password
,
strtoupper
(
$s
.
$algo
)
)
.
"
\n\n
"
;
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