Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
148a774b
Commit
148a774b
authored
21 years ago
by
jwindley
Browse files
Options
Downloads
Patches
Plain Diff
Instrument plugin code for debugging
parent
6f4647ff
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/common/plugin.c
+9
-1
9 additions, 1 deletion
src/common/plugin.c
src/common/plugin.h
+3
-0
3 additions, 0 deletions
src/common/plugin.h
src/common/plugrack.c
+62
-44
62 additions, 44 deletions
src/common/plugrack.c
src/common/plugrack.h
+2
-0
2 additions, 0 deletions
src/common/plugrack.h
with
76 additions
and
45 deletions
src/common/plugin.c
+
9
−
1
View file @
148a774b
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include
<dlfcn.h>
/* don't know if there's an autoconf for this. */
#include
<dlfcn.h>
/* don't know if there's an autoconf for this. */
#include
<string.h>
#include
<string.h>
#include
"src/common/log.h"
#include
"src/common/plugin.h"
#include
"src/common/plugin.h"
#include
<slurm/slurm_errno.h>
#include
<slurm/slurm_errno.h>
...
@@ -49,6 +50,7 @@ plugin_peek( const char *fq_path,
...
@@ -49,6 +50,7 @@ plugin_peek( const char *fq_path,
plug
=
dlopen
(
fq_path
,
RTLD_LAZY
);
plug
=
dlopen
(
fq_path
,
RTLD_LAZY
);
if
(
plug
==
NULL
)
{
if
(
plug
==
NULL
)
{
debug2
(
"plugin_peek: dlopen(%s): %s"
,
fq_path
,
dlerror
()
);
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
...
@@ -58,6 +60,7 @@ plugin_peek( const char *fq_path,
...
@@ -58,6 +60,7 @@ plugin_peek( const char *fq_path,
}
}
}
else
{
}
else
{
dlclose
(
plug
);
dlclose
(
plug
);
error
(
"%s: not a SLURM plugin"
,
fq_path
);
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
if
(
(
version
=
(
uint32_t
*
)
dlsym
(
plug
,
PLUGIN_VERSION
)
)
!=
NULL
)
{
if
(
(
version
=
(
uint32_t
*
)
dlsym
(
plug
,
PLUGIN_VERSION
)
)
!=
NULL
)
{
...
@@ -66,6 +69,7 @@ plugin_peek( const char *fq_path,
...
@@ -66,6 +69,7 @@ plugin_peek( const char *fq_path,
}
}
}
else
{
}
else
{
dlclose
(
plug
);
dlclose
(
plug
);
error
(
"%s: not a SLURM plugin"
,
fq_path
);
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
...
@@ -89,9 +93,12 @@ plugin_load_from_file( const char *fq_path )
...
@@ -89,9 +93,12 @@ plugin_load_from_file( const char *fq_path )
*/
*/
plug
=
dlopen
(
fq_path
,
RTLD_NOW
);
plug
=
dlopen
(
fq_path
,
RTLD_NOW
);
if
(
plug
==
NULL
)
{
if
(
plug
==
NULL
)
{
debug2
(
"plugin_load_from_file: dlopen(%s): %s"
,
fq_path
,
dlerror
()
);
return
PLUGIN_INVALID_HANDLE
;
return
PLUGIN_INVALID_HANDLE
;
}
}
/* Now see if our required symbols are defined. */
/* Now see if our required symbols are defined. */
if
(
(
dlsym
(
plug
,
PLUGIN_NAME
)
==
NULL
)
||
if
(
(
dlsym
(
plug
,
PLUGIN_NAME
)
==
NULL
)
||
(
dlsym
(
plug
,
PLUGIN_TYPE
)
==
NULL
)
||
(
dlsym
(
plug
,
PLUGIN_TYPE
)
==
NULL
)
||
...
@@ -106,6 +113,7 @@ plugin_load_from_file( const char *fq_path )
...
@@ -106,6 +113,7 @@ plugin_load_from_file( const char *fq_path )
*/
*/
if
(
(
init
=
dlsym
(
plug
,
"init"
)
)
!=
NULL
)
{
if
(
(
init
=
dlsym
(
plug
,
"init"
)
)
!=
NULL
)
{
if
(
(
*
init
)()
!=
0
)
{
if
(
(
*
init
)()
!=
0
)
{
debug
(
"plugin_load_from_file(%s): init() returned SLURM_ERROR"
,
fq_path
);
(
void
)
dlclose
(
plug
);
(
void
)
dlclose
(
plug
);
return
PLUGIN_INVALID_HANDLE
;
return
PLUGIN_INVALID_HANDLE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/common/plugin.h
+
3
−
0
View file @
148a774b
...
@@ -36,6 +36,9 @@
...
@@ -36,6 +36,9 @@
# include <stdint.h>
# include <stdint.h>
# endif
# endif
# endif
/* HAVE_INTTYPES_H */
# endif
/* HAVE_INTTYPES_H */
# if HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
#else
/* ! HAVE_CONFIG_H_ */
#else
/* ! HAVE_CONFIG_H_ */
# include <inttypes.h>
# include <inttypes.h>
#endif
/* HAVE_CONFIG_H */
#endif
/* HAVE_CONFIG_H */
...
...
This diff is collapsed.
Click to expand it.
src/common/plugrack.c
+
62
−
44
View file @
148a774b
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
# if !HAVE_STRCHR
# if !HAVE_STRCHR
# define strchr index
# define strchr index
# define strrchr rindex
# define strrchr rindex
char
*
strchr
(),
*
strrchr
();
char
*
strchr
(),
*
strrchr
();
# endif
/* HAVE_STRCHR */
# endif
/* HAVE_STRCHR */
# endif
/* STDC_HEADERS */
# endif
/* STDC_HEADERS */
...
@@ -163,19 +163,25 @@ accept_path_paranoia( plugrack_t rack,
...
@@ -163,19 +163,25 @@ accept_path_paranoia( plugrack_t rack,
xassert
(
fq_path
);
xassert
(
fq_path
);
if
(
stat
(
fq_path
,
&
st
)
<
0
)
{
if
(
stat
(
fq_path
,
&
st
)
<
0
)
{
debug3
(
"accept_path_paranoia: stat(%s) failed"
,
fq_path
);
return
0
;
return
0
;
}
}
/* Is path owned by authorized user? */
/* Is path owned by authorized user? */
if
(
check_own
)
{
if
(
check_own
)
{
if
(
st
.
st_uid
!=
rack
->
uid
)
return
0
;
if
(
st
.
st_uid
!=
rack
->
uid
)
{
debug3
(
"accept_path_paranoia: %s not owned by proper user"
,
fq_path
);
return
0
;
}
}
}
/* Is path writable by others? */
/* Is path writable by others? */
if
(
check_write
)
{
if
(
check_write
)
{
if
(
(
st
.
st_mode
&
S_IWGRP
)
if
(
(
st
.
st_mode
&
S_IWGRP
)
||
(
st
.
st_mode
&
S_IWOTH
)
)
||
(
st
.
st_mode
&
S_IWOTH
)
)
{
debug3
(
"accept_path_paranoia: %s writable by others"
,
fq_path
);
return
0
;
return
0
;
}
}
}
return
1
;
return
1
;
...
@@ -250,13 +256,17 @@ plugrack_open_plugin( plugrack_t rack, const char *fq_path )
...
@@ -250,13 +256,17 @@ plugrack_open_plugin( plugrack_t rack, const char *fq_path )
/* See if we can actually load the plugin. */
/* See if we can actually load the plugin. */
plug
=
plugin_load_from_file
(
fq_path
);
plug
=
plugin_load_from_file
(
fq_path
);
if
(
plug
==
PLUGIN_INVALID_HANDLE
)
return
PLUGIN_INVALID_HANDLE
;
if
(
plug
==
PLUGIN_INVALID_HANDLE
)
{
debug3
(
"plugrack_open_plugin: can't open %s"
,
fq_path
);
return
PLUGIN_INVALID_HANDLE
;
}
/* Now see if this is the right type. */
/* Now see if this is the right type. */
if
(
rack
->
major_type
if
(
rack
->
major_type
&&
(
strncmp
(
rack
->
major_type
,
&&
(
strncmp
(
rack
->
major_type
,
plugin_get_type
(
plug
),
plugin_get_type
(
plug
),
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
debug3
(
"plugrack_open_plugin: %s is of wrong type"
,
fq_path
);
plugin_unload
(
plug
);
plugin_unload
(
plug
);
return
PLUGIN_INVALID_HANDLE
;
return
PLUGIN_INVALID_HANDLE
;
}
}
...
@@ -297,6 +307,7 @@ plugrack_destroy( plugrack_t rack )
...
@@ -297,6 +307,7 @@ plugrack_destroy( plugrack_t rack )
it
=
list_iterator_create
(
rack
->
entries
);
it
=
list_iterator_create
(
rack
->
entries
);
while
(
(
e
=
list_next
(
it
)
)
!=
NULL
)
{
while
(
(
e
=
list_next
(
it
)
)
!=
NULL
)
{
if
(
e
->
refcount
>
0
)
{
if
(
e
->
refcount
>
0
)
{
debug2
(
"plugrack_destroy: attempt to destroy plugin rack that is still in use"
);
list_iterator_destroy
(
it
);
list_iterator_destroy
(
it
);
return
SLURM_ERROR
;
/* plugins still in use. */
return
SLURM_ERROR
;
/* plugins still in use. */
}
}
...
@@ -323,7 +334,10 @@ plugrack_set_major_type( plugrack_t rack, const char *type )
...
@@ -323,7 +334,10 @@ plugrack_set_major_type( plugrack_t rack, const char *type )
/* Install a new one. */
/* Install a new one. */
if
(
type
!=
NULL
)
{
if
(
type
!=
NULL
)
{
rack
->
major_type
=
xstrdup
(
type
);
rack
->
major_type
=
xstrdup
(
type
);
if
(
rack
->
major_type
==
NULL
)
return
SLURM_ERROR
;
if
(
rack
->
major_type
==
NULL
)
{
debug3
(
"plugrack_set_major_type: unable to set type"
);
return
SLURM_ERROR
;
}
}
}
return
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
...
@@ -348,8 +362,8 @@ plugrack_set_paranoia( plugrack_t rack,
...
@@ -348,8 +362,8 @@ plugrack_set_paranoia( plugrack_t rack,
static
int
static
int
plugrack_add_plugin_path
(
plugrack_t
rack
,
plugrack_add_plugin_path
(
plugrack_t
rack
,
const
char
*
full_type
,
const
char
*
full_type
,
const
char
*
fq_path
)
const
char
*
fq_path
)
{
{
plugrack_entry_t
*
e
;
plugrack_entry_t
*
e
;
...
@@ -372,8 +386,8 @@ plugrack_add_plugin_path( plugrack_t rack,
...
@@ -372,8 +386,8 @@ plugrack_add_plugin_path( plugrack_t rack,
int
int
plugrack_add_plugin_file
(
plugrack_t
rack
,
const
char
*
fq_path
)
plugrack_add_plugin_file
(
plugrack_t
rack
,
const
char
*
fq_path
)
{
{
static
const
size_t
type_len
=
64
;
static
const
size_t
type_len
=
64
;
char
plugin_type
[
type_len
];
char
plugin_type
[
type_len
];
if
(
!
rack
)
return
SLURM_ERROR
;
if
(
!
rack
)
return
SLURM_ERROR
;
if
(
!
fq_path
)
return
SLURM_ERROR
;
if
(
!
fq_path
)
return
SLURM_ERROR
;
...
@@ -385,18 +399,18 @@ plugrack_add_plugin_file( plugrack_t rack, const char *fq_path )
...
@@ -385,18 +399,18 @@ plugrack_add_plugin_file( plugrack_t rack, const char *fq_path )
*/
*/
if
(
!
accept_paranoia
(
rack
,
fq_path
)
)
return
SLURM_ERROR
;
if
(
!
accept_paranoia
(
rack
,
fq_path
)
)
return
SLURM_ERROR
;
/* Test the type. */
/* Test the type. */
if
(
plugin_peek
(
fq_path
,
if
(
plugin_peek
(
fq_path
,
plugin_type
,
plugin_type
,
type_len
,
type_len
,
NULL
)
==
SLURM_ERROR
)
{
NULL
)
==
SLURM_ERROR
)
{
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
if
(
rack
->
major_type
if
(
rack
->
major_type
&&
(
strncmp
(
rack
->
major_type
,
&&
(
strncmp
(
rack
->
major_type
,
plugin_type
,
plugin_type
,
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
/* Add it to the list. */
/* Add it to the list. */
...
@@ -414,8 +428,8 @@ plugrack_read_dir( plugrack_t rack,
...
@@ -414,8 +428,8 @@ plugrack_read_dir( plugrack_t rack,
DIR
*
dirp
;
DIR
*
dirp
;
struct
dirent
*
e
;
struct
dirent
*
e
;
struct
stat
st
;
struct
stat
st
;
static
const
size_t
type_len
=
64
;
static
const
size_t
type_len
=
64
;
char
plugin_type
[
type_len
];
char
plugin_type
[
type_len
];
if
(
!
rack
)
return
SLURM_ERROR
;
if
(
!
rack
)
return
SLURM_ERROR
;
if
(
!
dir
)
return
SLURM_ERROR
;
if
(
!
dir
)
return
SLURM_ERROR
;
...
@@ -446,7 +460,10 @@ plugrack_read_dir( plugrack_t rack,
...
@@ -446,7 +460,10 @@ plugrack_read_dir( plugrack_t rack,
/* Open the directory. */
/* Open the directory. */
dirp
=
opendir
(
dir
);
dirp
=
opendir
(
dir
);
if
(
dirp
==
NULL
)
return
SLURM_ERROR
;
if
(
dirp
==
NULL
)
{
error
(
"cannot open plugin directory %s"
,
dir
);
return
SLURM_ERROR
;
}
while
(
1
)
{
while
(
1
)
{
e
=
readdir
(
dirp
);
e
=
readdir
(
dirp
);
...
@@ -454,9 +471,9 @@ plugrack_read_dir( plugrack_t rack,
...
@@ -454,9 +471,9 @@ plugrack_read_dir( plugrack_t rack,
/*
/*
* Compose file name. Where NAME_MAX is defined it represents
* Compose file name. Where NAME_MAX is defined it represents
* the largest file name given in a dirent. This macro is used
* the largest file name given in a dirent. This macro is used
* in the allocation of "tail" above, so this unbounded copy
* in the allocation of "tail" above, so this unbounded copy
* should work.
* should work.
*/
*/
strcpy
(
tail
,
e
->
d_name
);
strcpy
(
tail
,
e
->
d_name
);
...
@@ -466,27 +483,28 @@ plugrack_read_dir( plugrack_t rack,
...
@@ -466,27 +483,28 @@ plugrack_read_dir( plugrack_t rack,
/* See if we should be paranoid about this file. */
/* See if we should be paranoid about this file. */
if
(
!
accept_path_paranoia
(
rack
,
if
(
!
accept_path_paranoia
(
rack
,
dir
,
fq_path
,
rack
->
paranoia
&
rack
->
paranoia
&
PLUGRACK_PARANOIA_FILE_OWN
,
PLUGRACK_PARANOIA_FILE_OWN
,
rack
->
paranoia
&
rack
->
paranoia
&
PLUGRACK_PARANOIA_FILE_WRITABLE
))
{
PLUGRACK_PARANOIA_FILE_WRITABLE
))
{
debug3
(
"plugin_read_dir: skipping %s for security reasons"
,
fq_path
);
continue
;
continue
;
}
}
/* Test the type. */
/* Test the type. */
if
(
plugin_peek
(
fq_path
,
if
(
plugin_peek
(
fq_path
,
plugin_type
,
plugin_type
,
type_len
,
type_len
,
NULL
)
==
SLURM_ERROR
)
{
NULL
)
==
SLURM_ERROR
)
{
continue
;
continue
;
}
}
if
(
rack
->
major_type
if
(
rack
->
major_type
&&
(
strncmp
(
rack
->
major_type
,
&&
(
strncmp
(
rack
->
major_type
,
plugin_type
,
plugin_type
,
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
strlen
(
rack
->
major_type
)
)
!=
0
)
)
{
continue
;
continue
;
}
}
/* Add it to the list. */
/* Add it to the list. */
(
void
)
plugrack_add_plugin_path
(
rack
,
plugin_type
,
fq_path
);
(
void
)
plugrack_add_plugin_path
(
rack
,
plugin_type
,
fq_path
);
...
@@ -518,7 +536,7 @@ plugrack_purge_idle( plugrack_t rack )
...
@@ -518,7 +536,7 @@ plugrack_purge_idle( plugrack_t rack )
it
=
list_iterator_create
(
rack
->
entries
);
it
=
list_iterator_create
(
rack
->
entries
);
while
(
(
e
=
list_next
(
it
)
)
!=
NULL
)
{
while
(
(
e
=
list_next
(
it
)
)
!=
NULL
)
{
if
(
(
e
->
plug
!=
PLUGIN_INVALID_HANDLE
)
&&
if
(
(
e
->
plug
!=
PLUGIN_INVALID_HANDLE
)
&&
(
e
->
refcount
==
0
)
){
(
e
->
refcount
==
0
)
){
plugin_unload
(
e
->
plug
);
plugin_unload
(
e
->
plug
);
e
->
plug
=
PLUGIN_INVALID_HANDLE
;
e
->
plug
=
PLUGIN_INVALID_HANDLE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/common/plugrack.h
+
2
−
0
View file @
148a774b
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
#ifndef __PLUGRACK_H__
#ifndef __PLUGRACK_H__
#define __PLUGRACK_H__
#define __PLUGRACK_H__
#include
<sys/types.h>
#include
"src/common/plugin.h"
#include
"src/common/plugin.h"
#include
"src/common/list.h"
#include
"src/common/list.h"
...
...
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