-
Notifications
You must be signed in to change notification settings - Fork 484
Rewrite/refactor delagent and fix #273 #646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite/refactor delagent and fix #273 #646
Conversation
@shaheemazmalmmd: even with the debugger i was not able to find the difference in PGresult * PQexecCheck(const char *desc, char *SQL, char *file, const int line)
{
PGresult *result;
[...]
result = PQexec(db_conn, SQL);
if (fo_checkPQcommand(db_conn, result, SQL, file, line))
{
exit(-1);
}
return result;
}
[...]
#if 0
result = PQexecCheck(NULL, SQL, __FILE__, __LINE__);
#else
result = PQexec(db_conn, SQL);
if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__))
{
exit(-1);
}
#endif
[...] I would suggest to remove the
|
5d77b16
to
b4645c4
Compare
@shaheemazmalmmd: I have already rebased it but I can revert it if you have problems with that. |
no, good that you rebased it. i missed it yesterday. |
I think that we have to have a look at the tests for delagent. I think at least the functional agent tests are outdated and also the unit tests should be extended.
|
|
@shaheemazmalmmd: I have manually tested that PR and it looks OK. Do you have any ideas what could be missing? Otherwise I would ask @steffen-weber or @wuan to review this PR. After that I might squash the commits and remove that silly BUT: I am still not able to run the functional tests. The used scripts
seam to be outdated. I think their functionality should be replaced by the php classes
But in this environment one has no deployed |
fd6355d
to
9d846a2
Compare
any user who is admin or owner can delete the folder, not all users
* pass the variables `user_id` and `user_perm` to all functions where they are needed * extract the permission checks into three functions (for uploads, folders, licenses) * start adding the permission checks into the correct places (not done yet, not tested yet) * move `admin_folder_delete.php` to `delagent/ui` * general rewriting of the delagent partly based on work by @shaheemazmalmmd
9d846a2
to
eb1856a
Compare
Hello, we need someone to review this PR. Maybe @wuan or @steffen-weber? Or maybe even @fogninid since this is essentially c-code? When someone volunteers, I will support him actively and give an overview on the changes. |
... and more refactoring by @shaheemazmalmmd: style(delagent): Alignment of code removed tabs and added spaces
* TODO: add tests!
* in `src/delagent/ui/admin-upload-delete.php` was no check for permissions, this enabled eveyone to delete every file with the correct POST-request
eb1856a
to
639221c
Compare
src/delagent/agent/delagent.c
Outdated
|
||
|
||
/*********************************************** | ||
Usage(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer all function names and variable names to be start with lower case. It should be uniform at least.
int check_permission_folder(long folder_id, int user_id, int user_perm); | ||
int check_permission_license(long license_id, int user_perm); | ||
|
||
/* functions that list things */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the captital letter at the start signify anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is just the style the code was written...
I will refactor the returncodes tomorrow |
1cd77fe
to
bf14882
Compare
if (ReadParameter(Parm) < 0) | ||
exit(-1); | ||
returnedCode = listUploads(user_id, user_perm); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if returnedCode != 0 you might want to leave the program here before you set it again if listFolder is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Its fixed now
bf14882
to
579b71b
Compare
|
||
writeMessageAfterDelete("upload", delUpload, user_name, returnedCode); | ||
} | ||
if (delFolder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, or are delUpload and delFolder mutually exclusive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function writeMessageAfterDelete
keeps track of that and exits if the returned code is not 0
- rewritten /refactored functions: - `DeleteUpload` - `DeleteLicense` - `UnlinkContent` - and more - rewrite naming of `TempTable` - remove all unnecessary `memset` calls - make return codes more consistend - remove dead code - die on permission failure - this change was made to show delagent jobs, which have had permission problems, as failed agents (i.e. red).
* The function `SHA1(...)` could generate strings containing `\000` which did not work with the following call of `strlen(...)` * This is solved, since one knows that a SHA1 hash as hex is 40 characters long (20 chars for the raw value) * The old test, whether the creation of the sha1 failed, can not work since the first char could also be `\000` ==> removed
as suggested by @joshovi
`rc=0` should always be the "good" case `rc>0` is a permission problem `rc<0` is a database connection problem, which has to be propagated out
4958b92
to
cc17579
Compare
This PR
this will fix #273
see #602 for the discussion on the previous PR concerned with this issue
This PR should not be merged yet.