Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
02a2a407
Commit
02a2a407
authored
Oct 17, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: converted permissions to unsigned
client->permission is a bit set, and should be unsigned.
parent
f8d5b740
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
22 deletions
+22
-22
client.c
src/client.c
+3
-3
client.h
src/client.h
+2
-2
command.c
src/command.c
+7
-7
permission.c
src/permission.c
+8
-8
permission.h
src/permission.h
+2
-2
No files found.
src/client.c
View file @
02a2a407
...
@@ -72,7 +72,7 @@ struct client {
...
@@ -72,7 +72,7 @@ struct client {
size_t
bufferPos
;
size_t
bufferPos
;
int
fd
;
/* file descriptor; -1 if expired */
int
fd
;
/* file descriptor; -1 if expired */
int
permission
;
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
/** the uid of the client process, or -1 if unknown */
int
uid
;
int
uid
;
...
@@ -115,12 +115,12 @@ int client_get_uid(const struct client *client)
...
@@ -115,12 +115,12 @@ int client_get_uid(const struct client *client)
return
client
->
uid
;
return
client
->
uid
;
}
}
int
client_get_permission
(
const
struct
client
*
client
)
unsigned
client_get_permission
(
const
struct
client
*
client
)
{
{
return
client
->
permission
;
return
client
->
permission
;
}
}
void
client_set_permission
(
struct
client
*
client
,
int
permission
)
void
client_set_permission
(
struct
client
*
client
,
unsigned
permission
)
{
{
client
->
permission
=
permission
;
client
->
permission
=
permission
;
}
}
...
...
src/client.h
View file @
02a2a407
...
@@ -43,9 +43,9 @@ int client_is_expired(const struct client *client);
...
@@ -43,9 +43,9 @@ int client_is_expired(const struct client *client);
*/
*/
int
client_get_uid
(
const
struct
client
*
client
);
int
client_get_uid
(
const
struct
client
*
client
);
int
client_get_permission
(
const
struct
client
*
client
);
unsigned
client_get_permission
(
const
struct
client
*
client
);
void
client_set_permission
(
struct
client
*
client
,
int
permission
);
void
client_set_permission
(
struct
client
*
client
,
unsigned
permission
);
/**
/**
* Write a block of data to the client.
* Write a block of data to the client.
...
...
src/command.c
View file @
02a2a407
...
@@ -138,7 +138,7 @@ struct _CommandEntry {
...
@@ -138,7 +138,7 @@ struct _CommandEntry {
const
char
*
cmd
;
const
char
*
cmd
;
int
min
;
int
min
;
int
max
;
int
max
;
int
reqPermission
;
unsigned
reqPermission
;
CommandHandlerFunction
handler
;
CommandHandlerFunction
handler
;
};
};
...
@@ -272,7 +272,7 @@ static int print_playlist_result(struct client *client,
...
@@ -272,7 +272,7 @@ static int print_playlist_result(struct client *client,
}
}
static
void
addCommand
(
const
char
*
name
,
static
void
addCommand
(
const
char
*
name
,
int
reqPermission
,
unsigned
reqPermission
,
int
minargs
,
int
minargs
,
int
maxargs
,
int
maxargs
,
CommandHandlerFunction
handler_func
)
CommandHandlerFunction
handler_func
)
...
@@ -1124,7 +1124,7 @@ static int handlePing(mpd_unused struct client *client,
...
@@ -1124,7 +1124,7 @@ static int handlePing(mpd_unused struct client *client,
static
int
handlePassword
(
struct
client
*
client
,
static
int
handlePassword
(
struct
client
*
client
,
mpd_unused
int
argc
,
char
*
argv
[])
mpd_unused
int
argc
,
char
*
argv
[])
{
{
int
permission
=
0
;
unsigned
permission
=
0
;
if
(
getPermissionFromPassword
(
argv
[
1
],
&
permission
)
<
0
)
{
if
(
getPermissionFromPassword
(
argv
[
1
],
&
permission
)
<
0
)
{
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
command_error
(
client
,
ACK_ERROR_PASSWORD
,
"incorrect password"
);
...
@@ -1192,7 +1192,7 @@ static int handleDevices(struct client *client,
...
@@ -1192,7 +1192,7 @@ static int handleDevices(struct client *client,
static
int
handleCommands
(
struct
client
*
client
,
static
int
handleCommands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
int
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
CommandEntry
*
cmd
;
...
@@ -1211,7 +1211,7 @@ static int handleCommands(struct client *client,
...
@@ -1211,7 +1211,7 @@ static int handleCommands(struct client *client,
static
int
handleNotcommands
(
struct
client
*
client
,
static
int
handleNotcommands
(
struct
client
*
client
,
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
mpd_unused
int
argc
,
mpd_unused
char
*
argv
[])
{
{
const
int
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
ListNode
*
node
=
commandList
->
firstNode
;
ListNode
*
node
=
commandList
->
firstNode
;
CommandEntry
*
cmd
;
CommandEntry
*
cmd
;
...
@@ -1348,7 +1348,7 @@ void finishCommands(void)
...
@@ -1348,7 +1348,7 @@ void finishCommands(void)
}
}
static
int
checkArgcAndPermission
(
CommandEntry
*
cmd
,
struct
client
*
client
,
static
int
checkArgcAndPermission
(
CommandEntry
*
cmd
,
struct
client
*
client
,
int
permission
,
int
argc
,
char
*
argv
[])
unsigned
permission
,
int
argc
,
char
*
argv
[])
{
{
int
min
=
cmd
->
min
+
1
;
int
min
=
cmd
->
min
+
1
;
int
max
=
cmd
->
max
+
1
;
int
max
=
cmd
->
max
+
1
;
...
@@ -1385,7 +1385,7 @@ static int checkArgcAndPermission(CommandEntry * cmd, struct client *client,
...
@@ -1385,7 +1385,7 @@ static int checkArgcAndPermission(CommandEntry * cmd, struct client *client,
}
}
static
CommandEntry
*
getCommandEntryAndCheckArgcAndPermission
(
struct
client
*
client
,
static
CommandEntry
*
getCommandEntryAndCheckArgcAndPermission
(
struct
client
*
client
,
int
permission
,
unsigned
permission
,
int
argc
,
int
argc
,
char
*
argv
[])
char
*
argv
[])
{
{
...
...
src/permission.c
View file @
02a2a407
...
@@ -34,11 +34,11 @@
...
@@ -34,11 +34,11 @@
static
List
*
permission_passwords
;
static
List
*
permission_passwords
;
static
int
permission_default
;
static
unsigned
permission_default
;
static
int
parsePermissions
(
char
*
string
)
static
unsigned
parsePermissions
(
char
*
string
)
{
{
int
permission
=
0
;
unsigned
permission
=
0
;
char
*
temp
;
char
*
temp
;
char
*
tok
;
char
*
tok
;
...
@@ -70,7 +70,7 @@ void initPermissions(void)
...
@@ -70,7 +70,7 @@ void initPermissions(void)
char
*
temp
;
char
*
temp
;
char
*
cp2
;
char
*
cp2
;
char
*
password
;
char
*
password
;
int
*
permission
;
unsigned
*
permission
;
ConfigParam
*
param
;
ConfigParam
*
param
;
permission_passwords
=
makeList
(
free
,
1
);
permission_passwords
=
makeList
(
free
,
1
);
...
@@ -99,7 +99,7 @@ void initPermissions(void)
...
@@ -99,7 +99,7 @@ void initPermissions(void)
password
=
temp
;
password
=
temp
;
permission
=
xmalloc
(
sizeof
(
int
));
permission
=
xmalloc
(
sizeof
(
unsigned
));
*
permission
=
*
permission
=
parsePermissions
(
strtok_r
(
NULL
,
""
,
&
cp2
));
parsePermissions
(
strtok_r
(
NULL
,
""
,
&
cp2
));
...
@@ -116,12 +116,12 @@ void initPermissions(void)
...
@@ -116,12 +116,12 @@ void initPermissions(void)
sortList
(
permission_passwords
);
sortList
(
permission_passwords
);
}
}
int
getPermissionFromPassword
(
char
*
password
,
int
*
permission
)
int
getPermissionFromPassword
(
char
*
password
,
unsigned
*
permission
)
{
{
void
*
foundPermission
;
void
*
foundPermission
;
if
(
findInList
(
permission_passwords
,
password
,
&
foundPermission
))
{
if
(
findInList
(
permission_passwords
,
password
,
&
foundPermission
))
{
*
permission
=
*
((
int
*
)
foundPermission
);
*
permission
=
*
((
unsigned
*
)
foundPermission
);
return
0
;
return
0
;
}
}
...
@@ -133,7 +133,7 @@ void finishPermissions(void)
...
@@ -133,7 +133,7 @@ void finishPermissions(void)
freeList
(
permission_passwords
);
freeList
(
permission_passwords
);
}
}
int
getDefaultPermissions
(
void
)
unsigned
getDefaultPermissions
(
void
)
{
{
return
permission_default
;
return
permission_default
;
}
}
src/permission.h
View file @
02a2a407
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
#define PERMISSION_ADMIN 8
#define PERMISSION_ADMIN 8
int
getPermissionFromPassword
(
char
*
password
,
int
*
permission
);
int
getPermissionFromPassword
(
char
*
password
,
unsigned
*
permission
);
void
finishPermissions
(
void
);
void
finishPermissions
(
void
);
int
getDefaultPermissions
(
void
);
unsigned
getDefaultPermissions
(
void
);
void
initPermissions
(
void
);
void
initPermissions
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment