diff --git a/src/delagent/agent/delagent.c b/src/delagent/agent/delagent.c index abd36339..b217ecb6 100644 --- a/src/delagent/agent/delagent.c +++ b/src/delagent/agent/delagent.c @@ -1,179 +1,267 @@ /******************************************************** delagent: Remove an upload from the DB and repository Copyright (C) 2007-2013 Hewlett-Packard Development Company, L.P. + Copyright (C) 2015-2016 Siemens AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ********************************************************/ /** * \file delagent.c * \brief main for delagent * * delagent: Remove an upload from the DB and repository */ #include "delagent.h" #ifdef COMMIT_HASH_S char BuildVersion[]="delagent build version: " VERSION_S " r(" COMMIT_HASH_S ").\n"; #else char BuildVersion[]="delagent build version: NULL.\n"; #endif +/*********************************************** + usage(): + Command line options allow you to write the agent so it works + stand alone, in addition to working with the scheduler. + This simplifies code development and testing. + So if you have options, have a usage(). + Here are some suggested options (in addition to the program + specific options you may already have). + ***********************************************/ +void usage (char *Name) +{ + fprintf(stderr,"Usage: %s [options]\n",Name); + fprintf(stderr," List or delete uploads.\n"); + fprintf(stderr," Options\n"); + fprintf(stderr," -i :: Initialize the DB, then exit.\n"); + fprintf(stderr," -u :: List uploads IDs.\n"); + fprintf(stderr," -U # :: Delete upload ID.\n"); + //fprintf(stderr," -L # :: Delete ALL licenses associated with upload ID.\n"); + fprintf(stderr," -f :: List folder IDs.\n"); + fprintf(stderr," -F # :: Delete folder ID and all uploads under this folder.\n"); + fprintf(stderr," Folder '1' is the default folder. '-F 1' will delete\n"); + fprintf(stderr," every upload and folder in the navigation tree.\n"); + fprintf(stderr," -s :: Run from the scheduler.\n"); + fprintf(stderr," -T :: TEST -- do not update the DB or delete any files (just pretend)\n"); + fprintf(stderr," -v :: Verbose (-vv for more verbose)\n"); + fprintf(stderr," -c # :: Specify the directory for the system configuration\n"); + fprintf(stderr," -V :: print the version info, then exit.\n"); + fprintf(stderr," --user|-n # :: user name\n"); + fprintf(stderr," --password|-p # :: password\n"); +} /* usage() */ + +void writeMessageAfterDelete(char *kind, long id, char *user_name, int returnedCode) +{ + if (0 == returnedCode) + { + fprintf(stdout, "The %s '%ld' is deleted by the user '%s'.\n", kind, id, user_name); + } + else + { + fprintf(stdout, "Deletion failed: user '%s' does not have the permsssion to delete the %s '%ld', or the %s '%ld' does not exist.\n", user_name, kind, id, kind, id); + exit(returnedCode); + } +} + /** * \brief main function for the delagent * * There are 2 ways to use the delagent agent: - * 1. Command Line :: delete/list upload from the command line + * 1. Command Line :: delete/list upload/folder/license from the command line * 2. Agent Based :: run from the scheduler * * +-----------------------+ * | Command Line Analysis | * +-----------------------+ * * List or delete uploads. - * -h :: help (print this message), then exit. - * -i :: Initialize the DB - * -u :: List uploads IDs. - * -U # :: Delete upload ID. - * -L # :: Delete ALL licenses associated with upload ID. - * -f :: List folder IDs. - * -F # :: Delete folder ID and all uploads under this folder. - * -T :: TEST -- do not update the DB or delete any files (just pretend). - * -v :: Verbose (-vv for more verbose). - * -V :: print the version info, then exit. + * -h :: help (print this message), then exit. + * -i :: Initialize the DB + * -u :: List uploads IDs. + * -U # :: Delete upload ID. + * -L # :: Delete ALL licenses associated with upload ID. + * -f :: List folder IDs. + * -F # :: Delete folder ID and all uploads under this folder. + * -T :: TEST -- do not update the DB or delete any files (just pretend). + * -v :: Verbose (-vv for more verbose). + * -V :: print the version info, then exit. * -c SYSCONFDIR :: Specify the directory for the system configuration. - * --user # :: user name + * --user # :: user name * --password # :: password * * +----------------------+ * | Agent Based Analysis | * +----------------------+ * * To run the delagent as an agent * -s :: Run from the scheduler * * * \param argc the number of command line arguments * \param argv the command line arguments * \return 0 on a successful program execution */ int main (int argc, char *argv[]) { int c; - int ListProj=0, ListFolder=0; - long DelUpload=0, DelFolder=0, DelLicense=0; - int Scheduler=0; /* should it run from the scheduler? */ - int GotArg=0; + int listProj=0, listFolder=0; + long delUpload=0, delFolder=0, delLicense=0; + int scheduler=0; /* should it run from the scheduler? */ + int gotArg=0; char *agent_desc = "Deletes upload. Other list/delete options available from the command line."; - char *Parm = NULL; - //int Agent_pk = 0; char *COMMIT_HASH; char *VERSION; char agent_rev[myBUFSIZ]; int option_index = 0; char *user_name = NULL; char *password = NULL; int user_id = -1; int user_perm = -1; + int returnedCode = 0; fo_scheduler_connect(&argc, argv, &db_conn); static struct option long_options[] = { {"user", required_argument, 0, 'n'}, {"password", required_argument, 0, 'p'}, {0, 0, 0, 0} }; - + while ((c = getopt_long (argc, argv, "n:p:ifF:lL:sTuU:vVc:h", long_options, &option_index)) != -1) { switch (c) { - case 'n': + case 'n': user_name = optarg; - break; + break; case 'p': password = optarg; break; case 'i': PQfinish(db_conn); return(0); - case 'f': ListFolder=1; GotArg=1; break; - case 'F': DelFolder=atol(optarg); GotArg=1; break; - case 'L': DelLicense=atol(optarg); GotArg=1; break; - case 's': Scheduler=1; GotArg=1; break; - case 'T': Test++; break; - case 'u': ListProj=1; GotArg=1; break; - case 'U': DelUpload=atol(optarg); GotArg=1; break; - case 'v': Verbose++; break; - case 'c': GotArg=1; break; /* handled by fo_scheduler_connect() */ - case 'V': printf("%s", BuildVersion); PQfinish(db_conn); return(0); - default: Usage(argv[0]); exit(-1); + case 'f': + listFolder=1; + gotArg=1; + break; + case 'F': + delFolder=atol(optarg); + gotArg=1; + break; + case 'L': + delLicense=atol(optarg); + gotArg=1; + break; + case 's': + scheduler=1; + gotArg=1; + break; + case 'T': + Test++; + break; + case 'u': + listProj=1; + gotArg=1; + break; + case 'U': + delUpload=atol(optarg); + gotArg=1; + break; + case 'v': + Verbose++; + break; + case 'c': + gotArg=1; + break; /* handled by fo_scheduler_connect() */ + case 'V': + printf("%s", BuildVersion); + PQfinish(db_conn); + return(0); + default: + usage(argv[0]); + exit(-1); } } - if (!GotArg) - { - Usage(argv[0]); - exit(-1); - } - - if (Scheduler != 1 && 1 != authentication(user_name, password, &user_id, &user_perm)) + if (!gotArg) { - LOG_FATAL("User name or password is invalid.\n"); + usage(argv[0]); exit(-1); } - COMMIT_HASH = fo_sysconfig("delagent", "COMMIT_HASH"); - VERSION = fo_sysconfig("delagent", "VERSION"); - sprintf(agent_rev, "%s.%s", VERSION, COMMIT_HASH); - /* Get the Agent Key from the DB */ - fo_GetAgentKey(db_conn, basename(argv[0]), 0, agent_rev, agent_desc); - - if (ListProj) ListUploads(user_id, user_perm); - if (ListFolder) ListFolders(user_id); - - alarm(60); /* from this point on, handle the alarm */ - if (DelUpload) + if (scheduler != 1) { - if (1 != check_permission_del(DelUpload, user_id, user_perm)) + if (0 != authentication(user_name, password, &user_id, &user_perm)) { - LOG_FATAL("You '%s' does not have the permsssion to delete the upload '%ld', or the upload '%ld' does not exist.\n", user_name, DelUpload, DelUpload); + LOG_FATAL("User name or password is invalid.\n"); exit(-1); } - DeleteUpload(DelUpload); - fprintf(stdout, "The upload '%ld' is deleted by the user '%s'.\n", DelUpload, user_name); - } - if (DelFolder) { DeleteFolder(DelFolder); } - if (DelLicense) { DeleteLicense(DelLicense); } - /* process from the scheduler */ - if (Scheduler) - { - while(fo_scheduler_next()) + COMMIT_HASH = fo_sysconfig("delagent", "COMMIT_HASH"); + VERSION = fo_sysconfig("delagent", "VERSION"); + sprintf(agent_rev, "%s.%s", VERSION, COMMIT_HASH); + /* Get the Agent Key from the DB */ + fo_GetAgentKey(db_conn, basename(argv[0]), 0, agent_rev, agent_desc); + + if (listProj) { - Parm = fo_scheduler_current(); - - if (ReadParameter(Parm) < 0) - exit(-1); + returnedCode = listUploads(user_id, user_perm); } + if (returnedCode < 0) + { + return returnedCode; + } + if (listFolder) + { + returnedCode = listFolders(user_id, user_perm); + } + if (returnedCode < 0) + { + return returnedCode; + } + + alarm(60); /* from this point on, handle the alarm */ + if (delUpload) + { + returnedCode = deleteUpload(delUpload, user_id, user_perm); + + writeMessageAfterDelete("upload", delUpload, user_name, returnedCode); + } + if (delFolder) + { + returnedCode = deleteFolder(delFolder, user_id, user_perm); + + writeMessageAfterDelete("folder", delFolder, user_name, returnedCode); + } + if (delLicense) + { + returnedCode = deleteLicense(delLicense, user_perm); + + writeMessageAfterDelete("license", delLicense, user_name, returnedCode); + } + } + else + { + /* process from the scheduler */ + doSchedulerTasks(); } + fo_scheduler_disconnect(0); PQfinish(db_conn); - fo_scheduler_disconnect(0); - return(0); + return(returnedCode); } /* main() */ - diff --git a/src/delagent/agent/delagent.h b/src/delagent/agent/delagent.h index 4fcaaeec..5623b5a1 100644 --- a/src/delagent/agent/delagent.h +++ b/src/delagent/agent/delagent.h @@ -1,59 +1,71 @@ /******************************************************** Copyright (C) 2007-2012 Hewlett-Packard Development Company, L.P. + Copyright (C) 2015-2016 Siemens AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ********************************************************/ #ifndef _DELAGENT_H #define _DELAGENT_H 1 #include #include #include #include #include #include #include #include #include #include #include #include #include "libfossology.h" extern int Verbose; extern int Test; /* for DB */ extern PGconn* db_conn; #define MAXSQL 1024 #define MAXLINE 1024 #define myBUFSIZ 2048 -#define ADMIN_PERM 10 - -void DeleteLicense(long UploadId); -void DeleteUpload(long UploadId); -void ListFoldersRecurse(long Parent, int Depth, long Row, int DelFlag); -int UnlinkContent (long child, long parent, int mode); -void ListFolders(int user_id); -void ListUploads (int user_id, int user_perm); -void DeleteFolder(long FolderId); -int ReadParameter(char *Parm); -void Usage(char *Name); + +/* authentication and permission checking */ int authentication(char *user, char * password, int *user_id, int *user_perm); -int check_permission_del(long upload_id, int user_id, int user_perm); + +int check_permission_upload(int wantedPermissions, long upload_id, int user_id, int user_perm); +int check_read_permission_upload(long upload_id, int user_id, int user_perm); +int check_write_permission_upload(long upload_id, int user_id, int user_perm); +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 */ +int listFolders(int user_id, int user_perm); +int listUploads(int user_id, int user_perm); + +/* function that delete actual things */ +int deleteLicense(long UploadId, int user_perm); +int deleteUpload(long UploadId, int user_id, int user_perm); +int deleteFolder(long FolderId, int user_id, int user_perm); + +/* for usage from scheduler */ +void doSchedulerTasks(); + +/* misc */ +void usage(char *Name); #endif /* _DELAGENT_H */ diff --git a/src/delagent/agent/util.c b/src/delagent/agent/util.c index ffa62468..662a5a6a 100644 --- a/src/delagent/agent/util.c +++ b/src/delagent/agent/util.c @@ -1,988 +1,1042 @@ /******************************************************** Copyright (C) 2007-2013 Hewlett-Packard Development Company, L.P. + Copyright (C) 2015-2016 Siemens AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ********************************************************/ /** * \file util.c * \brief local function of delagent * * delagent: Remove an upload from the DB and repository * */ #include "delagent.h" int Verbose = 0; int Test = 0; PGconn* db_conn = NULL; // the connection to Database +int printfInCaseOfVerbosity (const char *format, ...) +{ + va_list arg; + int done = 0; + + if (Verbose) + { + va_start (arg, format); + done = vprintf(format, arg); + va_end (arg); + } + return done; +} + +/** + * \brief PQexecCheck() + * + * simple wrapper which includes PQexec and fo_checkPQcommand + * + */ +PGresult * PQexecCheck(const char *desc, char *SQL, char *file, const int line) +{ + PGresult *result; + + if(desc == NULL) + { + printfInCaseOfVerbosity("# %s:%i: %s\n", file, line, SQL); + } + else + { + printfInCaseOfVerbosity("# %s:%i: %s (%s)\n", file, line, desc, SQL); + } + + result = PQexec(db_conn, SQL); + if (fo_checkPQcommand(db_conn, result, SQL, file, line)) + { + exit(-1); + } + return result; +} + +void PQexecCheckClear(const char *desc, char *SQL, char *file, const int line) +{ + PGresult *result; + result = PQexecCheck(desc, SQL, file, line); + PQclear(result); +} + +/** + * \brief if this account is valid + * + * \param char *user - user name + * \param char *password - password + * \param int *user_id - will be set to the id of the user + * \param int *user_perm - will be set to the permission level of the user + * + * \return 1: invalid; + * 0: yes, valid; + * -1: failure + */ +int authentication(char *user, char *password, int *user_id, int *user_perm) +{ + if (NULL == user || NULL == password) + { + return 1; + } + char SQL[MAXSQL] = {0}; + PGresult *result; + char user_seed[myBUFSIZ] = {0}; + char pass_hash_valid[41] = {0}; + unsigned char pass_hash_actual_raw[21] = {0}; + char pass_hash_actual[41] = {0}; + + /** get user_seed, user_pass on one specified user */ + snprintf(SQL,MAXSQL,"SELECT user_seed, user_pass, user_perm, user_pk from users where user_name=$1;"); + const char *values[1] = {user}; + int lengths[1] = {strlen(user)}; + int binary[1] = {0}; + result = PQexecParams(db_conn, SQL, 1, NULL, values, lengths, binary, 0); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) + { + return -1; + } + if (!PQntuples(result)) + { + return 1; + } + strcpy(user_seed, PQgetvalue(result, 0, 0)); + strcpy(pass_hash_valid, PQgetvalue(result, 0, 1)); + *user_perm = atoi(PQgetvalue(result, 0, 2)); + *user_id = atoi(PQgetvalue(result, 0, 3)); + PQclear(result); + if (user_seed[0] && pass_hash_valid[0]) + { + strcat(user_seed, password); // get the hash code on seed+pass + SHA1((unsigned char *)user_seed, strlen(user_seed), pass_hash_actual_raw); + } + else + { + return -1; + } + int i = 0; + char temp[256] = {0}; + for (i = 0; i < 20; i++) + { + snprintf(temp, 256, "%02x", pass_hash_actual_raw[i]); + strcat(pass_hash_actual, temp); + } + return (strcmp(pass_hash_valid, pass_hash_actual) == 0) ? 0 : 1; +} + +/** + * \brief check if the upload can be deleted, that is the user have + * the permission to delete this upload + * + * \param long upload_id - upload id + * \param char *user_name - user name + * + * \return 0: yes, you have the needed permissions; + * 1: no; + * -1: failure; + * -2: does not exist + */ +int check_permission_upload(int wanted_permissions, long upload_id, int user_id, int user_perm) +{ + int perms = getEffectivePermissionOnUpload(db_conn, upload_id, user_id, user_perm); + if (perms > 0) + { + if (perms < wanted_permissions) + { + return 1; + } + else + { + return 0; + } + } + return perms; +} + +int check_read_permission_upload(long upload_id, int user_id, int user_perm) +{ + return check_permission_upload(PERM_READ, upload_id, user_id, user_perm); +} + +int check_write_permission_upload(long upload_id, int user_id, int user_perm) +{ + return check_permission_upload(PERM_WRITE, upload_id, user_id, user_perm); +} + /** - * \brief DeleteLicense() - * + * \brief check if the upload can be deleted, that is the user have + * the permission to delete this upload + * + * \param long upload_id - upload id + * \param char *user_name - user name + * + * \return 0: yes, can be deleted; + * 1: can not be deleted; + * -1: failure; + */ +int check_write_permission_folder(long folder_id, int user_id, int user_perm) +{ + char SQL[MAXSQL]; + PGresult *result; + int count = 0; + + if (user_perm < PERM_WRITE) + { + return 1; // can not be deleted + } + + snprintf(SQL,MAXSQL,"SELECT count(*) FROM folder join users on (users.user_pk = folder.user_fk or users.user_perm = 10) where folder_pk = %ld and users.user_pk = %d;",folder_id,user_id); + result = PQexec(db_conn, SQL); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) + { + return -1; + } + count = atol(PQgetvalue(result,0,0)); + if(count == 0) + { + return 1; // can not be deleted + } + return 0; // can be deleted +} + +/** + * \brief check if the upload can be deleted, that is the user have + * the permissoin to delete this upload + * + * \param long upload_id - upload id + * \param char *user_name - user name + * + * \return 0: yes, can be deleted; + * 1: can not be deleted; + */ +int check_write_permission_license(long license_id, int user_perm) +{ + if (user_perm != PERM_ADMIN) + { + printfInCaseOfVerbosity("only admin is allowed to delete licenses\n"); + return 0; // can not be deleted + } + return 1; // can be deleted +} + + +/** + * \brief deleteLicense() + * * Given an upload ID, delete all licenses associated with it. * The DoBegin flag determines whether BEGIN/COMMIT should be called. * Do this if you want to reschedule license analysis. * * \param long UploadId the upload id + * + * \return 0: yes, success; + * 1: can not be deleted; + * -1: failure; + * -2: does not exist */ -void DeleteLicense (long UploadId) +int deleteLicense (long UploadId, int user_perm) { - char TempTable[256]; char SQL[MAXSQL]; PGresult *result; long items=0; - if (Verbose) { printf("Deleting licenses for upload %ld\n",UploadId); } - - result = PQexec(db_conn, "SET statement_timeout = 0;"); /* no timeout */ - if (fo_checkPQcommand(db_conn, result, "SET statement_timeout = 0;", __FILE__, __LINE__)) exit(-1); - PQclear(result); - result = PQexec(db_conn, "BEGIN;"); - if (fo_checkPQcommand(db_conn, result, "BEGIN;", __FILE__, __LINE__)) exit(-1); - PQclear(result); - - memset(TempTable,'\0',sizeof(TempTable)); - snprintf(TempTable,sizeof(TempTable),"DelLic_%ld",UploadId); + int permission_license = check_write_permission_license(UploadId, user_perm); + if (0 != permission_license) + { + return permission_license; + } - /* Create the temp table */ - if (Verbose) { printf("# Creating temp table: %s\n",TempTable); } + printfInCaseOfVerbosity("Deleting licenses for upload %ld\n",UploadId); + PQexecCheckClear(NULL, "SET statement_timeout = 0;", __FILE__, __LINE__); + PQexecCheckClear(NULL, "BEGIN;", __FILE__, __LINE__); /* Get the list of pfiles to process */ - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT DISTINCT(pfile_fk) FROM uploadtree WHERE upload_fk = '%ld' ;",UploadId); + snprintf(SQL,MAXSQL,"SELECT DISTINCT(pfile_fk) FROM uploadtree WHERE upload_fk = '%ld' ;",UploadId); result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) + { + return -1; + } items = PQntuples(result); PQclear(result); /***********************************************/ /* delete pfile licenses */ - if (Verbose) { printf("# Deleting licenses\n"); } - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"DELETE FROM licterm_name WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); + printfInCaseOfVerbosity("# Deleting licenses\n"); + snprintf(SQL,MAXSQL,"DELETE FROM licterm_name WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); + PQexecCheckClear(NULL, SQL, __FILE__, __LINE__); - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"DELETE FROM agent_lic_status WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); + snprintf(SQL,MAXSQL,"DELETE FROM agent_lic_status WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); + PQexecCheckClear(NULL, SQL, __FILE__, __LINE__); - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"DELETE FROM agent_lic_meta WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); + snprintf(SQL,MAXSQL,"DELETE FROM agent_lic_meta WHERE pfile_fk IN (SELECT pfile_fk FROM uploadtree WHERE upload_fk = '%ld');",UploadId); + PQexecCheckClear(NULL, SQL, __FILE__, __LINE__); fo_scheduler_heart(items); /***********************************************/ /* Commit the change! */ - if (Verbose) { printf("# Delete completed\n"); } + printfInCaseOfVerbosity("# Delete completed\n"); if (Test) { - result = PQexec(db_conn, "ROLLBACK;"); - if (fo_checkPQcommand(db_conn, result, "ROLLBACK", __FILE__, __LINE__)) exit(-1); - PQclear(result); + PQexecCheckClear(NULL, "ROLLBACK;", __FILE__, __LINE__); } else { - result = PQexec(db_conn, "COMMIT;"); - if (fo_checkPQcommand(db_conn, result, "COMMIT", __FILE__, __LINE__)) exit(-1); - PQclear(result); -#if 0 - /** Disabled: DB will take care of this **/ - if (Verbose) { printf("# Running vacuum and analyze\n"); } - MyDBaccess(DB,"VACUUM ANALYZE agent_lic_status;"); - MyDBaccess(DB,"VACUUM ANALYZE agent_lic_meta;"); -#endif - } - result = PQexec(db_conn, "SET statement_timeout = 120000;"); - if (fo_checkPQcommand(db_conn, result, "SET statement_timeout = 120000;", __FILE__, __LINE__)) exit(-1); - PQclear(result); + PQexecCheckClear(NULL, "COMMIT;", __FILE__, __LINE__); + } + PQexecCheckClear(NULL, "SET statement_timeout = 120000;", __FILE__, __LINE__); - if (Verbose) { printf("Deleted licenses for upload %ld\n",UploadId); } -} /* DeleteLicense() */ + printfInCaseOfVerbosity("Deleted licenses for upload %ld\n",UploadId); + + return 0; /* success */ +} /* deleteLicense() */ /** - * \brief DeleteUpload() - * - * Given an upload ID, delete it. + * \brief deleteUpload() + * +* Given an upload ID, delete it. * * param long UploadId the upload id + * + * \return 0: yes, can is deleted; + * 1: can not be deleted; + * -1: failure; + * -2: does not exist */ -void DeleteUpload (long UploadId) +int deleteUpload (long UploadId, int user_id, int user_perm) { char *S; int Row,MaxRow; char TempTable[256]; PGresult *result, *pfile_result; - char SQL[MAXSQL]; + char SQL[MAXSQL], desc[myBUFSIZ]; - if (Verbose) { printf("Deleting upload %ld\n",UploadId); } - result = PQexec(db_conn, "SET statement_timeout = 0;"); /* no timeout */ - if (fo_checkPQcommand(db_conn, result, "SET statement_timeout = 0;", __FILE__, __LINE__)) exit(-1); - PQclear(result); - result = PQexec(db_conn, "BEGIN;"); - if (fo_checkPQcommand(db_conn, result, "BEGIN;", __FILE__, __LINE__)) exit(-1); - PQclear(result); - - memset(TempTable,'\0',sizeof(TempTable)); - snprintf(TempTable,sizeof(TempTable),"DelUp_%ld",UploadId); + int permission_upload = check_write_permission_upload(UploadId, user_id, user_perm); + if(0 != permission_upload) + { + return permission_upload; + } + + snprintf(TempTable,sizeof(TempTable),"DelUp_%ld_pfile",UploadId); + snprintf(SQL,MAXSQL,"DROP TABLE IF EXISTS %s;",TempTable); + PQexecCheckClear(NULL, SQL, __FILE__, __LINE__); + + snprintf(desc, myBUFSIZ, "Deleting upload %ld",UploadId); + PQexecCheckClear(desc, "SET statement_timeout = 0;", __FILE__, __LINE__); + PQexecCheckClear(NULL, "BEGIN;", __FILE__, __LINE__); /***********************************************/ /*** Delete everything that impacts the UI ***/ /***********************************************/ - /***********************************************/ - /* Delete the upload from the folder-contents table */ - /* - memset(SQL,'\0',sizeof(SQL)); - if (Verbose) { printf("# Deleting foldercontents\n"); } - snprintf(SQL,sizeof(SQL),"DELETE FROM foldercontents WHERE (foldercontents_mode & 2) != 0 AND child_id = %ld;",UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); - */ - if (!Test) { /* The UI depends on uploadtree and folders for navigation. - Delete them now to block timeouts from the UI. */ - if (Verbose) { printf("# COMMIT;\n"); } - result = PQexec(db_conn, "COMMIT;"); - if (fo_checkPQcommand(db_conn, result, "COMMIT;", __FILE__, __LINE__)) exit(-1); - PQclear(result); - //if (Verbose) { printf("# BEGIN;\n"); } - //result = PQexec(db_conn, "BEGIN;"); - //if (fo_checkPQcommand(db_conn, result, "BEGIN;", __FILE__, __LINE__)) exit(-1); - //PQclear(result); + Delete them now to block timeouts from the UI. */ + PQexecCheckClear(NULL, "COMMIT;", __FILE__, __LINE__); } /***********************************************/ /*** Begin complicated stuff ***/ /***********************************************/ /* Get the list of pfiles to delete */ /** These are all pfiles in the upload_fk that only appear once. **/ - memset(SQL,'\0',sizeof(SQL)); - if (Verbose) { printf("# Getting list of pfiles to delete\n"); } - snprintf(SQL,sizeof(SQL),"SELECT DISTINCT pfile_pk,pfile_sha1 || '.' || pfile_md5 || '.' || pfile_size AS pfile INTO %s_pfile FROM uploadtree INNER JOIN pfile ON upload_fk = %ld AND pfile_fk = pfile_pk;",TempTable,UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); + snprintf(SQL,MAXSQL,"SELECT DISTINCT pfile_pk,pfile_sha1 || '.' || pfile_md5 || '.' || pfile_size AS pfile INTO %s FROM uploadtree INNER JOIN pfile ON upload_fk = %ld AND pfile_fk = pfile_pk;",TempTable,UploadId); + PQexecCheckClear("Getting list of pfiles to delete", + SQL, __FILE__, __LINE__); /* Remove pfiles with reuse */ - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"DELETE FROM %s_pfile USING uploadtree WHERE pfile_pk = uploadtree.pfile_fk AND uploadtree.upload_fk != %ld;",TempTable,UploadId); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); + snprintf(SQL,MAXSQL,"DELETE FROM %s USING uploadtree WHERE pfile_pk = uploadtree.pfile_fk AND uploadtree.upload_fk != %ld;",TempTable,UploadId); + PQexecCheckClear(NULL, SQL, __FILE__, __LINE__); - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT COUNT(*) FROM %s_pfile;",TempTable); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - if (Verbose) { printf("# Created pfile table: %ld entries\n",atol(PQgetvalue(result,0,0))); } - PQclear(result); + if (Verbose) + { + snprintf(SQL,MAXSQL,"SELECT COUNT(*) FROM %s;",TempTable); + result = PQexec(db_conn, SQL); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) + { + return -1; + } + printf("# Created pfile table %s with %ld entries\n", TempTable, atol(PQgetvalue(result,0,0))); + PQclear(result); + } + /***********************************************/ + /* Now to delete the actual pfiles from the repository before remove the DB. */ /* Get the file listing -- needed for deleting pfiles from the repository. */ - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT * FROM %s_pfile ORDER BY pfile_pk;",TempTable); + snprintf(SQL,MAXSQL,"SELECT * FROM %s ORDER BY pfile_pk;",TempTable); pfile_result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, pfile_result, SQL, __FILE__, __LINE__)) exit(-1); - MaxRow = PQntuples(pfile_result); + if (fo_checkPQresult(db_conn, pfile_result, SQL, __FILE__, __LINE__)) + { + return -1; + } - /***********************************************/ - /* Now to delete the actual pfiles from the repository before remove the DB. */ if (Test <= 1) { + MaxRow = PQntuples(pfile_result); for(Row=0; Row1 && !Test) { - for(Row=0; Row 0){ + return 1; + } /* Find all folders with this parent and recurse */ - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT folder_pk,foldercontents_mode,name,description,upload_pk FROM folderlist " + snprintf(SQL,MAXSQL,"SELECT folder_pk,foldercontents_mode,name,description,upload_pk FROM folderlist " "WHERE parent=%ld " "ORDER BY name,parent,folder_pk",Parent); result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) + { + return -1; + } MaxRow = PQntuples(result); for(r=0; r < MaxRow; r++) { if (atol(PQgetvalue(result,r,0)) == Parent) { continue; } - if (!DelFlag) - { - for(i=0; i1 && !Test) - { - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"DELETE FROM foldercontents WHERE foldercontents_mode=%d AND child_id =%ld AND parent_fk=%ld",mode,child,parent); - result = PQexec(db_conn, SQL); - if (fo_checkPQcommand(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - PQclear(result); - return 1; - } - return 0; -} - -/** - * \brief ListFolders(): List every folder. - */ -void ListFolders (int user_id) -{ - int i,j,MaxRow; - long Fid; /* folder ids */ int DetachFlag=0; + int i,j; + int MaxRow = PQntuples(result); + long Fid; /* folder ids */ int Match; char *Desc; - char SQL[MAXSQL]; - PGresult *result; - int cnt = 0; - - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"select count(*) from users where user_pk = %d and user_perm >= 1;",user_id); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - cnt = atol(PQgetvalue(result,0,0)); - if(user_id != 0 && cnt == 0){ - LOG_FATAL("user does not have the permsssion to view the folder list.\n"); - exit(-1); - } - printf("# Folders\n"); - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT folder_name from folder where folder_pk =1;"); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - - printf("%4d :: %s\n", 1, PQgetvalue(result,0,0)); - PQclear(result); - - memset(SQL,'\0',sizeof(SQL)); - snprintf(SQL,sizeof(SQL),"SELECT folder_pk,parent,name,description,upload_pk FROM folderlist ORDER BY name,parent,folder_pk;"); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) exit(-1); - ListFoldersRecurse(1,1,-1,0); + int rc; /* Find detached folders */ - MaxRow = PQntuples(result); - DetachFlag=0; for(i=0; i < MaxRow; i++) { Fid = atol(PQgetvalue(result,i,1)); - if (Fid == 1) continue; /* skip default parent */ + if (Fid == 1) + { + continue; /* skip default parent */ + } Match=0; for(j=0; (j= 0) + rc = check_read_permission_upload(NewPid, user_id, user_perm); + if (rc < 0) + { + PQclear(result); + return rc; + } + if (NewPid >= 0 && (user_perm == PERM_ADMIN || rc == 0)) { char *S; printf("%ld :: %s",NewPid,PQgetvalue(result,Row,2)); S = PQgetvalue(result,Row,1); if (S && S[0]) printf(" (%s)",S); printf("\n"); } } PQclear(result); -} /* ListUploads() */ + return 0; +} /* listUploads() */ /** - * \brief DeleteFolder() + * \brief deleteFolder() * * Given a folder ID, delete it AND recursively delete everything below it! * This includes upload deletion! - * + * * \param long FolderId the fold id to delete + * + * \return 0: success; + * 1: fail + * -1: failure + * **/ -void DeleteFolder (long FolderId) +int deleteFolder(long FolderId, int user_id, int user_perm) { - ListFoldersRecurse(FolderId,0,-1,2); -#if 0 - /** Disabled: Database will take care of this **/ - MyDBaccess(DB,"VACUUM ANALYZE foldercontents;"); - MyDBaccess(DB,"VACUUM ANALYZE folder;"); -#endif -} /* DeleteFolder() */ + return listFoldersRecurse(FolderId,0,-1,2,user_id,user_perm); +} /* deleteFolder() */ /**********************************************************************/ /** - * \brief ReadParameter() - * + * \brief readAndProcessParameter() + * * Read Parameter from scheduler. * Process line elements. * * \param char *Parm the parameter string - * - * \return 0 on OK, -1 on failure. + * + * \return 0: yes, can is deleted; + * 1: can not be deleted; + * -1: failure; + * -2: does not exist * **/ -int ReadParameter (char *Parm) +int readAndProcessParameter (char *Parm, int user_id, int user_perm) { - char FullLine[MAXLINE]; char *L; int rc=0; /* assume no data */ - int Type=0; /* 0=undefined; 1=delete; 2=list */ - int Target=0; /* 0=undefined; 1=upload; 2=license; 3=folder */ + int Type=0; /* 0=undefined; 1=delete; 2=list */ + int Target=0; /* 0=undefined; 1=upload; 2=license; 3=folder */ long Id; - memset(FullLine,0,MAXLINE); - if (!Parm) { return(-1); } if (Verbose > 1) fprintf(stderr,"DEBUG: Line='%s'\n",Parm); /* process the string. */ L = Parm; while(isspace(L[0])) L++; /** Get the type of command: delete or list **/ if (!strncasecmp(L,"DELETE",6) && isspace(L[6])) { Type=1; /* delete */ L+=6; } else if (!strncasecmp(L,"LIST",4) && isspace(L[4])) { Type=2; /* list */ L+=4; } while(isspace(L[0])) L++; /** Get the target **/ if (!strncasecmp(L,"UPLOAD",6) && (isspace(L[6]) || !L[6])) { Target=1; /* upload */ L+=6; } else if (!strncasecmp(L,"LICENSE",7) && (isspace(L[7]) || !L[7])) { Target=2; /* license */ L+=7; } else if (!strncasecmp(L,"FOLDER",6) && (isspace(L[6]) || !L[6])) { Target=3; /* folder */ L+=6; } while(isspace(L[0])) L++; Id = atol(L); /* Handle the request */ - if ((Type==1) && (Target==1)) { DeleteUpload(Id); rc=1; } - else if ((Type==1) && (Target==2)) { DeleteLicense(Id); rc=1; } - else if ((Type==1) && (Target==3)) { DeleteFolder(Id); rc=1; } - else if ((Type==2) && (Target==1)) { ListUploads(0, ADMIN_PERM); rc=1; } - else if ((Type==2) && (Target==2)) { ListUploads(0, ADMIN_PERM); rc=1; } - else if ((Type==2) && (Target==3)) { ListFolders(0); rc=1; } - else + if ((Type==1) && (Target==1)) { - LOG_FATAL("Unknown command: '%s'\n",Parm); + rc = deleteUpload(Id, user_id, user_perm); } - - return(rc); -} /* ReadParameter() */ - -/** - * \brief check if the upload can be deleted, that is the user have - * the permissin to delte this upload - * - * \param long upload_id - upload id - * \param char *user_name - user name - * - * \return 1: yes, can be deleted; -1: failure; 0: can not be deleted - */ -int check_permission_del(long upload_id, int user_id, int user_perm) -{ - char SQL[MAXSQL] = {0};; - PGresult *result = NULL; - int count = 0; - - snprintf(SQL,sizeof(SQL),"SELECT count(*) FROM upload join users on (users.user_pk = upload.user_fk or users.user_perm = 10) where upload_pk = %ld and users.user_pk = %d;", upload_id, user_id); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) return -1; - count = atoi(PQgetvalue(result, 0, 0)); - if (count == 0) return -2; // this upload does not exist - - /* Check Permissions */ - if (GetUploadPerm(db_conn, upload_id, user_id) < PERM_WRITE) + else if ((Type==1) && (Target==2)) { - LOG_ERROR("You have no update permissions on upload %ld", upload_id); - return 0; + rc = deleteLicense(Id, user_perm); + } + else if ((Type==1) && (Target==3)) + { + rc = deleteFolder(Id, user_id, user_perm); + } + else if (((Type==2) && (Target==1)) || ((Type==2) && (Target==2))) + { + rc = listUploads(0, PERM_ADMIN); + } + else if ((Type==2) && (Target==3)) + { + rc = listFolders(user_id, user_perm); + } + else + { + LOG_ERROR("Unknown command: '%s'\n",Parm); } - return 1; // can be deleted -} + return rc; +} /* readAndProcessParameter() */ -/** - * \brief if this account is valid - * - * \param char *user - ussr name - * \param char *password - password - * - * \return 1: yes, valid; -1: failure; 0: invalid - */ -int authentication(char *user, char * password, int *user_id, int *user_perm) +void doSchedulerTasks() { - if (NULL == user || NULL == password) return 0; - char SQL[MAXSQL] = {0}; + char *Parm = NULL; + char SQL[MAXSQL]; PGresult *result; - char user_seed[myBUFSIZ] = {0}; - char pass_hash_valid[myBUFSIZ] = {0}; - unsigned char hash_value[myBUFSIZ] = {0}; - char pass_hash_actual[myBUFSIZ] = {0}; + int user_id = -1; + int user_perm = -1; - /** get user_seed, user_pass on one specified user */ - snprintf(SQL,sizeof(SQL),"SELECT user_seed, user_pass, user_perm, user_pk from users where user_name='%s';", user); - result = PQexec(db_conn, SQL); - if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__)) return -1; - if (!PQntuples(result)){ - return 0; - } - strcpy(user_seed, PQgetvalue(result, 0, 0)); - strcpy(pass_hash_valid, PQgetvalue(result, 0, 1)); - *user_perm = atoi(PQgetvalue(result, 0, 2)); - *user_id = atoi(PQgetvalue(result, 0, 3)); - PQclear(result); - if (user_seed[0] && pass_hash_valid[0]) + while(fo_scheduler_next()) { - strcat(user_seed, password); // get the hash code on seed+pass - SHA1((unsigned char *)user_seed, strlen(user_seed), hash_value); - if (!hash_value[0]) + Parm = fo_scheduler_current(); + user_id = fo_scheduler_userID(); + + /* get perm level of user */ + snprintf(SQL,MAXSQL,"SELECT user_perm from users where user_pk='%d';", user_id); + result = PQexec(db_conn, SQL); + if (fo_checkPQresult(db_conn, result, SQL, __FILE__, __LINE__) || !PQntuples(result)) { - LOG_FATAL("ERROR, failed to get sha1 value\n"); - return -1; + exit(0); + } + user_perm = atoi(PQgetvalue(result, 0, 0)); + PQclear(result); + + int returnCode = readAndProcessParameter(Parm, user_id, user_perm); + if (returnCode != 0) + { + /* Loglevel is to high, but scheduler expects FATAL log message before exit */ + LOG_FATAL("Due to permission problems, the delagent was not able to list or delete the requested objects or they did not exist."); + exit(returnCode); } } - else return -1; - int i = 0; - char temp[256] = {0}; - for (i = 0; i < strlen((char *)hash_value); i++) - { - sprintf(temp, "%02x", hash_value[i]); - strcat(pass_hash_actual, temp); - } - if (strcmp(pass_hash_valid, pass_hash_actual) == 0) - { - return 1; - } - else return -1; } - -/*********************************************** - Usage(): - Command line options allow you to write the agent so it works - stand alone, in addition to working with the scheduler. - This simplifies code development and testing. - So if you have options, have a Usage(). - Here are some suggested options (in addition to the program - specific options you may already have). - ***********************************************/ -void Usage (char *Name) -{ - fprintf(stderr,"Usage: %s [options]\n",Name); - fprintf(stderr," List or delete uploads.\n"); - fprintf(stderr," Options\n"); - fprintf(stderr," -i :: Initialize the DB, then exit.\n"); - fprintf(stderr," -u :: List uploads IDs.\n"); - fprintf(stderr," -U # :: Delete upload ID.\n"); - //fprintf(stderr," -L # :: Delete ALL licenses associated with upload ID.\n"); - fprintf(stderr," -f :: List folder IDs.\n"); - fprintf(stderr," -F # :: Delete folder ID and all uploads under this folder.\n"); - fprintf(stderr," Folder '1' is the default folder. '-F 1' will delete\n"); - fprintf(stderr," every upload and folder in the navigation tree.\n"); - fprintf(stderr," -s :: Run from the scheduler.\n"); - fprintf(stderr," -T :: TEST -- do not update the DB or delete any files (just pretend)\n"); - fprintf(stderr," -v :: Verbose (-vv for more verbose)\n"); - fprintf(stderr," -c # :: Specify the directory for the system configuration\n"); - fprintf(stderr," -V :: print the version info, then exit.\n"); - fprintf(stderr," --user|-n # :: user name\n"); - fprintf(stderr," --password|-p # :: password\n"); -} /* Usage() */ diff --git a/src/www/ui/admin-folder-delete.php b/src/delagent/ui/admin-folder-delete.php similarity index 81% rename from src/www/ui/admin-folder-delete.php rename to src/delagent/ui/admin-folder-delete.php index ac527a5c..943def8f 100644 --- a/src/www/ui/admin-folder-delete.php +++ b/src/delagent/ui/admin-folder-delete.php @@ -1,131 +1,136 @@ Name = "admin_folder_delete"; $this->Title = TITLE_admin_folder_delete; $this->MenuList = "Organize::Folders::Delete Folder"; $this->Dependency = array(); $this->DBaccess = PLUGIN_DB_WRITE; parent::__construct(); $this->dbManager = $GLOBALS['container']->get('db.manager'); } /** * \brief Delete * Creates a job to detele the folder * * \param $folderpk - the folder_pk to remove * \return NULL on success, string on failure. */ - function Delete($folderpk, $Depends = NULL) + function Delete($folderpk, $userId) { /* Can't remove top folder */ if ($folderpk == FolderGetTop()) { $text = _("Can Not Delete Root Folder"); return ($text); } /* Get the folder's name */ $FolderName = FolderGetName($folderpk); /* Prepare the job: job "Delete" */ - $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); $jobpk = JobAddJob($userId, $groupId, "Delete Folder: $FolderName"); if (empty($jobpk) || ($jobpk < 0)) { $text = _("Failed to create job record"); return ($text); } /* Add job: job "Delete" has jobqueue item "delagent" */ $jqargs = "DELETE FOLDER $folderpk"; $jobqueuepk = JobQueueAdd($jobpk, "delagent", $jqargs, NULL, NULL); if (empty($jobqueuepk)) { $text = _("Failed to place delete in job queue"); return ($text); } /* Tell the scheduler to check the queue. */ $success = fo_communicate_with_scheduler("database", $output, $error_msg); if (!$success) return $error_msg . "\n" . $output; return (NULL); } // Delete() /** * \brief Generate the text for this plugin. */ public function Output() { /* If this is a POST, then process the request. */ $folder = GetParm('folder', PARM_INTEGER); if (!empty($folder)) { - $rc = $this->Delete($folder); - $sql = "SELECT * FROM folder where folder_pk = $1;"; - $Folder = $this->dbManager->getSingleRow($sql,array($folder),__METHOD__."GetRowWithFolderName"); - if (empty($rc)) { - /* Need to refresh the screen */ - $text = _("Deletion of folder "); - $text1 = _(" added to job queue"); - $this->vars['message'] = $text . $Folder['folder_name'] . $text1; - } - else { - $text = _("Deletion of "); - $text1 = _(" failed: "); - $this->vars['message'] = $text . $Folder['folder_name'] . $text1 . $rc; + $userId = Auth::getUserId(); + $sql = "SELECT folder_name FROM folder join users on (users.user_pk = folder.user_fk or users.user_perm = 10) where folder_pk = $1 and users.user_pk = $2;"; + $Folder = $this->dbManager->getSingleRow($sql,array($folder,$userId),__METHOD__."GetRowWithFolderName"); + if(!empty($Folder['folder_name'])){ + $rc = $this->Delete($folder, $userId); + if (empty($rc)) { + /* Need to refresh the screen */ + $text = _("Deletion of folder "); + $text1 = _(" added to job queue"); + $this->vars['message'] = $text . $Folder['folder_name'] . $text1; + }else{ + $text = _("Deletion of "); + $text1 = _(" failed: "); + $this->vars['message'] = $text . $Folder['folder_name'] . $text1 . $rc; + } + }else{ + $text = _("Cannot delete this folder :: Permission denied"); + $this->vars['message'] = $text; } } $V= "
\n"; // no url = this url $text = _("Select the folder to"); $text1 = _("delete"); $V.= "$text $text1.\n"; $V.= "
    \n"; $text = _("This will"); $text1 = _("delete"); $text2 = _("the folder, all subfolders, and all uploaded files stored within the folder!"); $V.= "
  • $text $text1 $text2\n"; $text = _("Be very careful with your selection since you can delete a lot of work!"); $V.= "
  • $text\n"; $text = _("All analysis only associated with the deleted uploads will also be deleted."); $V.= "
  • $text\n"; $text = _("THERE IS NO UNDELETE. When you select something to delete, it will be removed from the database and file repository."); $V.= "
  • $text\n"; $V.= "
\n"; $text = _("Select the folder to delete: "); $V.= "

$text\n"; $V.= "

\n"; $text = _("Delete"); $V.= "\n"; $V.= "

\n"; return $V; } } $NewPlugin = new admin_folder_delete; diff --git a/src/delagent/ui/admin-upload-delete.php b/src/delagent/ui/admin-upload-delete.php index 7b735742..a4fdcd5c 100644 --- a/src/delagent/ui/admin-upload-delete.php +++ b/src/delagent/ui/admin-upload-delete.php @@ -1,173 +1,187 @@ Name = "admin_upload_delete"; $this->Title = TITLE_admin_upload_delete; $this->MenuList = "Organize::Uploads::Delete Uploaded File"; $this->DBaccess = PLUGIN_DB_WRITE; parent::__construct(); } + /** + * \brief Given a folder_pk, try to add a job after checking permissions. + * \param $uploadpk - the upload(upload_id) you want to delete + * + * \return string with the message. + */ + function TryToDelete($uploadpk) { + if (! GetUploadPerm($uploadpk) >= Auth::PERM_WRITE) { + $text=_("You dont have permissions to delete the upload"); + return DisplayMessage($text); + } + + $rc = $this->Delete($uploadpk); + + if (! empty($rc)) { + $text=_("Deletion Scheduling failed: "); + return DisplayMessage($text.$rc); + } + + /* Need to refresh the screen */ + $URL = Traceback_uri() . "?mod=showjobs&upload=$uploadpk "; + $LinkText = _("View Jobs"); + $text=_("Deletion added to job queue."); + $msg = "$text $LinkText"; + return displayMessage($msg); + } + /** * \brief Given a folder_pk, add a job. * \param $uploadpk - the upload(upload_id) you want to delete * \param $Depends - Depends is not used for now * * \return NULL on success, string on failure. */ function Delete($uploadpk, $Depends = NULL) { - global $SysConf; - /* Prepare the job: job "Delete" */ $user_pk = Auth::getUserId(); $group_pk = Auth::getGroupId(); $jobpk = JobAddJob($user_pk, $group_pk, "Delete", $uploadpk); if (empty($jobpk) || ($jobpk < 0)) { $text = _("Failed to create job record"); return ($text); } /* Add job: job "Delete" has jobqueue item "delagent" */ $jqargs = "DELETE UPLOAD $uploadpk"; $jobqueuepk = JobQueueAdd($jobpk, "delagent", $jqargs, NULL, NULL); if (empty($jobqueuepk)) { $text = _("Failed to place delete in job queue"); return ($text); } /* Tell the scheduler to check the queue. */ $success = fo_communicate_with_scheduler("database", $output, $error_msg); if (!$success) { $error_msg = _("Is the scheduler running? Your jobs have been added to job queue."); $URL = Traceback_uri() . "?mod=showjobs&upload=$uploadpk "; $LinkText = _("View Jobs"); $msg = "$error_msg $LinkText"; return $msg; } return (NULL); } // Delete() /** * \brief Generate the text for this plugin. */ public function Output() { $V = ""; /* If this is a POST, then process the request. */ $uploadpk = GetParm('upload', PARM_INTEGER); if (!empty($uploadpk)) { - $rc = $this->Delete($uploadpk); - if (empty($rc)) { - /* Need to refresh the screen */ - $URL = Traceback_uri() . "?mod=showjobs&upload=$uploadpk "; - $LinkText = _("View Jobs"); - $text=_("Deletion added to job queue."); - $msg = "$text $LinkText"; - $V.= displayMessage($msg); - } - else { - $text=_("Deletion Scheduling failed: "); - $V.= DisplayMessage($text.$rc); - } + $V.= $this->TryToDelete($uploadpk); } /* Create the AJAX (Active HTTP) javascript for doing the reply and showing the response. */ $V.= ActiveHTTPscript("Uploads"); $V.= "\n"; /* Build HTML form */ $V.= "
\n"; // no url = this url $text = _("Select the uploaded file to"); $text1 = _("delete"); $V.= "$text $text1\n"; $V.= "
    \n"; $text = _("This will"); $text1 = _("delete"); $text2 = _("the upload file!"); $V.= "
  • $text $text1 $text2\n"; $text = _("Be very careful with your selection since you can delete a lot of work!\n"); $V.= "
  • $text"; $text = _("All analysis only associated with the deleted upload file will also be deleted.\n"); $V.= "
  • $text"; $text = _("THERE IS NO UNDELETE. When you select something to delete, it will be removed from the database and file repository.\n"); $V.= "
  • $text"; $V.= "
\n"; $text = _("Select the uploaded file to delete:"); $V.= "

$text

\n"; $V.= "

    \n"; $text = _("Select the folder containing the file to delete: "); $V.= "
  1. $text"; $V.= "

    \n"; $text = _("Select the uploaded project to delete:"); $V.= "

  2. $text"; $V.= "
    \n"; $V.= "

    \n"; $V.= "

    \n"; $V.= "
\n"; $text = _("Delete"); $V.= "\n"; $V.= "
\n"; return $V; } } $NewPlugin = new admin_upload_delete; diff --git a/src/lib/c/libfossagent.c b/src/lib/c/libfossagent.c index 51f3eaad..8eb47e99 100644 --- a/src/lib/c/libfossagent.c +++ b/src/lib/c/libfossagent.c @@ -1,329 +1,387 @@ /*************************************************************** libfossagent: Set of generic functions handy for agent development. Copyright (C) 2009-2013 Hewlett-Packard Development Company, L.P. Copyright (C) 2015 Siemens AG This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***************************************************************/ /*! * \file libfossagent.c * \brief libfossagent.c contains general use functions for agents. */ #include "libfossology.h" #define FUNCTION char* getUploadTreeTableName(fo_dbManager* dbManager, int uploadId) { char* result; PGresult* resTableName = fo_dbManager_ExecPrepared( fo_dbManager_PrepareStamement( dbManager, "getUploadTreeTableName", "SELECT uploadtree_tablename from upload where upload_pk=$1 limit 1", int), uploadId ); if (!resTableName) { result = g_strdup("uploadtree"); return result; } if (PQntuples(resTableName) == 0) { PQclear(resTableName); result = g_strdup("uploadtree"); return result; } result = g_strdup(PQgetvalue(resTableName, 0, 0)); PQclear(resTableName); return result; } PGresult* queryFileIdsForUpload(fo_dbManager* dbManager, int uploadId) { PGresult* result; char* uploadtreeTableName = getUploadTreeTableName(dbManager, uploadId); if (strcmp(uploadtreeTableName, "uploadtree_a") == 0) { char* queryName = g_strdup_printf("queryFileIdsForUpload.%s", uploadtreeTableName); char* sql; sql = g_strdup_printf("select distinct(pfile_fk) from %s where upload_fk=$1 and (ufile_mode&x'3C000000'::int)=0", uploadtreeTableName); result = fo_dbManager_ExecPrepared( fo_dbManager_PrepareStamement( dbManager, queryName, sql, int), uploadId ); g_free(sql); g_free(queryName); } else { result = fo_dbManager_Exec_printf(dbManager, "select distinct(pfile_fk) from %s where (ufile_mode&x'3C000000'::int)=0", uploadtreeTableName ); } g_free(uploadtreeTableName); return result; } char* queryPFileForFileId(fo_dbManager* dbManager, long fileId) { PGresult* fileNameResult = fo_dbManager_ExecPrepared( fo_dbManager_PrepareStamement( dbManager, "queryPFileForFileId", "select pfile_sha1 || '.' || pfile_md5 ||'.'|| pfile_size AS pfilename from pfile where pfile_pk=$1", long), fileId ); if (PQntuples(fileNameResult) == 0) { PQclear(fileNameResult); return NULL; } char* pFile = g_strdup(PQgetvalue(fileNameResult, 0, 0)); PQclear(fileNameResult); return pFile; } /*! \brief Get the latest enabled agent key (agent_pk) from the database. \param pgConn Database connection object pointer. \param agent_name Name of agent to look up. \param Upload_pk is no longer used. \param rev agent revision, if given this is the exact revision of the agent being requested. \param agent_desc Description of the agent. Used to write a new agent record in the case where no enabled agent records exist for this agent_name. \return On success return agent_pk. On sql failure, return 0, and the error will be written to stdout. - \todo This function is not checking if the agent is enabled. And it is not setting + \todo This function is not checking if the agent is enabled. And it is not setting agent version when an agent record is inserted. */ FUNCTION int fo_GetAgentKey(PGconn* pgConn, const char* agent_name, long Upload_pk, const char* rev, const char* agent_desc) { int Agent_pk = -1; /* agent identifier */ char sql[256]; char sqlselect[256]; char sqlupdate[256]; PGresult* result; /* get the exact agent rec requested */ sprintf(sqlselect, "SELECT agent_pk,agent_desc FROM agent WHERE agent_name ='%s' order by agent_ts desc limit 1", agent_name); result = PQexec(pgConn, sqlselect); if (fo_checkPQresult(pgConn, result, sqlselect, __FILE__, __LINE__)) return 0; if (PQntuples(result) == 0) { PQclear(result); /* no match, so add an agent rec */ sprintf(sql, "INSERT INTO agent (agent_name,agent_desc,agent_enabled,agent_rev) VALUES ('%s',E'%s','%d', '%s')", agent_name, agent_desc, 1, rev); result = PQexec(pgConn, sql); if (fo_checkPQcommand(pgConn, result, sqlselect, __FILE__, __LINE__)) return 0; result = PQexec(pgConn, sqlselect); if (fo_checkPQresult(pgConn, result, sqlselect, __FILE__, __LINE__)) return 0; } Agent_pk = atol(PQgetvalue(result, 0, 0)); /* Compare agent_desc */ if(!(strcmp(PQgetvalue(result, 0, 1),agent_desc) == 0)){ PQclear(result); - sprintf(sqlupdate, "UPDATE agent SET agent_desc = E'%s' where agent_pk = '%d'",agent_desc, Agent_pk); + sprintf(sqlupdate, "UPDATE agent SET agent_desc = E'%s' where agent_pk = '%d'",agent_desc, Agent_pk); result = PQexec(pgConn, sqlupdate); } PQclear(result); return Agent_pk; } /* fo_GetAgentKey() */ /** \brief Write ars record If the ars table does not exist, one is created by inheriting the ars_master table. The new table is called {tableName}. For example, "unpack_ars". If ars_pk is zero a new ars record will be created. Otherwise, it is updated. \param pgConn Database connection object pointer. \param ars_pk If zero, a new record will be created. \param upload_pk \parm agent_pk Agents should get this from fo_GetAgentKey() \param tableName ars table name \parm ars_status Status to update ars_status. May be null. \parm ars_success Automatically set to false if ars_pk is zero. \return On success write the ars record and return the ars_pk. On sql failure, return 0, and the error will be written to stdout. */ FUNCTION int fo_WriteARS(PGconn* pgConn, int ars_pk, int upload_pk, int agent_pk, const char* tableName, const char* ars_status, int ars_success) { char sql[1024]; PGresult* result; /* does ars table exist? If not, create it. */ if (!fo_CreateARSTable(pgConn, tableName)) return (0); - /* If ars_pk is null, - * write the ars_status=false record + /* If ars_pk is null, + * write the ars_status=false record * and return the ars_pk. */ if (!ars_pk) { snprintf(sql, sizeof(sql), "insert into %s (agent_fk, upload_fk) values(%d,%d)", tableName, agent_pk, upload_pk); result = PQexec(pgConn, sql); if (fo_checkPQcommand(pgConn, result, sql, __FILE__, __LINE__)) return 0; /* get primary key */ snprintf(sql, sizeof(sql), "SELECT currval('nomos_ars_ars_pk_seq')"); result = PQexec(pgConn, sql); if (fo_checkPQresult(pgConn, result, sql, __FILE__, __LINE__)) return (0); ars_pk = atoi(PQgetvalue(result, 0, 0)); PQclear(result); } else { /* If ars_pk is not null, update success, status and endtime */ if (ars_status) { snprintf(sql, sizeof(sql), "update %s set ars_success=%s, ars_status='%s',ars_endtime=now() where ars_pk = %d", tableName, ars_success ? "True" : "False", ars_status, ars_pk); } else { snprintf(sql, sizeof(sql), "update %s set ars_success=%s, ars_endtime=now() where ars_pk = %d", tableName, ars_success ? "True" : "False", ars_pk); } result = PQexec(pgConn, sql); if (fo_checkPQcommand(pgConn, result, sql, __FILE__, __LINE__)) return 0; } return (ars_pk); } /* fo_WriteARS() */ /** \brief Create ars table if it doesn't already exist. \param pgConn Database connection object pointer. \param tableName ars table name \return 0 on failure */ FUNCTION int fo_CreateARSTable(PGconn* pgConn, const char* tableName) { char sql[1024]; PGresult* result; if (fo_tableExists(pgConn, tableName)) return 1; // table already exists snprintf(sql, sizeof(sql), "create table %s() inherits(ars_master);\ ALTER TABLE ONLY %s ADD CONSTRAINT %s_agent_fk_fkc FOREIGN KEY (agent_fk) REFERENCES agent(agent_pk);\ ALTER TABLE ONLY %s ADD CONSTRAINT %s_upload_fk_fkc FOREIGN KEY (upload_fk) REFERENCES upload(upload_pk) ON DELETE CASCADE;", tableName, tableName, tableName, tableName, tableName); /* ALTER TABLE ONLY %s ADD CONSTRAINT %s_pkey1 PRIMARY KEY (ars_pk); \ */ result = PQexec(pgConn, sql); if (fo_checkPQcommand(pgConn, result, sql, __FILE__, __LINE__)) return 0; return 1; /* success */ } /* fo_CreateARSTable() */ +FUNCTION int max(int permGroup, int permPublic) +{ + return ( permGroup > permPublic ) ? permGroup : permPublic; +} + +FUNCTION int min(int user_perm, int permExternal) +{ + return ( user_perm < permExternal ) ? user_perm: permExternal; +} + +/** +* \brief Get users permission to this upload +* +* \param pgConn Database connection object pointer. +* \param long upload_pk +* \param user_pk +* \param user_perm +* +* \return permission (PERM_) this user has for UploadPk +*/ +FUNCTION int getEffectivePermissionOnUpload(PGconn* pgConn, long UploadPk, int user_pk, int user_perm) +{ + PGresult* result; + char SQL[1024]; + int permGroup=0, permPublic=0; + + + /* Get the user permission level for this upload */ + snprintf(SQL, sizeof(SQL), + "select max(perm) as perm \ + from perm_upload, group_user_member \ + where perm_upload.upload_fk=%ld \ + and user_fk=%d \ + and group_user_member.group_fk=perm_upload.group_fk", + UploadPk, user_pk); + result = PQexec(pgConn, SQL); + if (!fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__) + && PQntuples(result) > 0) + { + permGroup = atoi(PQgetvalue(result, 0, 0)); + } + PQclear(result); + + /* Get the public permission level */ + snprintf(SQL, sizeof(SQL), + "select public_perm \ + from upload \ + where upload_pk=%ld", + UploadPk); + result = PQexec(pgConn, SQL); + fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__); + if (!fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__) + && PQntuples(result) > 0) + { + permPublic = atoi(PQgetvalue(result, 0, 0)); + } + PQclear(result); + + return min(user_perm, max(permGroup, permPublic)); +} /** * \brief Get users permission to this upload * * \param pgConn Database connection object pointer. * \param long upload_pk * \param user_pk * * \return permission (PERM_) this user has for UploadPk */ FUNCTION int GetUploadPerm(PGconn* pgConn, long UploadPk, int user_pk) { PGresult* result; char SQL[1024]; - int perm; + int user_perm; /* Check the users PLUGIN_DB level. PLUGIN_DB_ADMIN are superusers. */ snprintf(SQL, sizeof(SQL), "select user_perm from users where user_pk='%d'", user_pk); result = PQexec(pgConn, SQL); fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__); if (PQntuples(result) < 1) { LOG_ERROR("No records returned in %s", SQL); - return 0; + return PERM_NONE; } - perm = atoi(PQgetvalue(result, 0, 0)); + user_perm = atoi(PQgetvalue(result, 0, 0)); PQclear(result); - if (perm >= PLUGIN_DB_ADMIN) return (PERM_ADMIN); + if (user_perm >= PLUGIN_DB_ADMIN) + { + return PERM_ADMIN; + } - /* Get the user permission level */ - snprintf(SQL, sizeof(SQL), "select max(perm) as perm from perm_upload, group_user_member where perm_upload.upload_fk=%ld and user_fk=%d and group_user_member.group_fk=perm_upload.group_fk", UploadPk, user_pk); - result = PQexec(pgConn, SQL); - fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__); - perm = atoi(PQgetvalue(result, 0, 0)); - return (PERM_ADMIN); + return getEffectivePermissionOnUpload(pgConn, UploadPk, user_pk, user_perm); } /** * \brief Get the uploadtree table name for this upload_pk * If upload_pk does not exist, return "uploadtree". * * \param pgConn Database connection object pointer. * \param upload_pk * * \return uploadtree table name, or null if upload_pk does not exist. * Caller must free the (non-null) returned value. */ FUNCTION char* GetUploadtreeTableName(PGconn* pgConn, int upload_pk) { PGresult* result; char* uploadtree_tablename = 0; char SQL[1024]; /* Get the uploadtree table name from the upload table */ snprintf(SQL, sizeof(SQL), "select uploadtree_tablename from upload where upload_pk='%d'", upload_pk); result = PQexec(pgConn, SQL); fo_checkPQresult(pgConn, result, SQL, __FILE__, __LINE__); if (PQntuples(result) == 1) uploadtree_tablename = g_strdup(PQgetvalue(result, 0, 0)); PQclear(result); return (uploadtree_tablename); } diff --git a/src/lib/c/libfossagent.h b/src/lib/c/libfossagent.h index 2c1d8132..ac882ed6 100644 --- a/src/lib/c/libfossagent.h +++ b/src/lib/c/libfossagent.h @@ -1,37 +1,38 @@ /************************************************************** Copyright (C) 20011 Hewlett-Packard Development Company, L.P. Copyright (C) 2015 Siemens AG This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc.0 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA **************************************************************/ #ifndef LIBFOSSAGENT_H #define LIBFOSSAGENT_H #include #include #include #include "libfossdbmanager.h" char* getUploadTreeTableName(fo_dbManager* dbManager, int uploadId); PGresult* queryFileIdsForUpload(fo_dbManager* dbManager, int uploadId); char* queryPFileForFileId(fo_dbManager* dbManager, long int fileId); int fo_GetAgentKey(PGconn* pgConn, const char* agent_name, long unused, const char* cpunused, const char* agent_desc); int fo_WriteARS(PGconn* pgConn, int ars_pk, int upload_pk, int agent_pk, const char* tableName, const char* ars_status, int ars_success); int fo_CreateARSTable(PGconn* pgConn, const char* table_name); +int getEffectivePermissionOnUpload(PGconn* pgConn, long UploadPk, int user_pk, int user_perm); int GetUploadPerm(PGconn* pgConn, long UploadPk, int user_pk); char* GetUploadtreeTableName(PGconn* pgConn, int upload_pk); #endif diff --git a/src/lib/php/Dao/FolderDao.php b/src/lib/php/Dao/FolderDao.php index b27e7e99..cfcfc0ba 100644 --- a/src/lib/php/Dao/FolderDao.php +++ b/src/lib/php/Dao/FolderDao.php @@ -1,406 +1,406 @@ dbManager = $dbManager; $this->logger = new Logger(self::className()); $this->uploadDao = $uploadDao; $this->userDao = $userDao; } /** * @return boolean */ public function hasTopLevelFolder() { $folderInfo = $this->dbManager->getSingleRow("SELECT count(*) cnt FROM folder WHERE folder_pk=$1",array(self::TOP_LEVEL),__METHOD__); $hasFolder = $folderInfo['cnt']>0; return $hasFolder; } public function insertFolder($folderName, $folderDescription, $parentFolderId=self::TOP_LEVEL) { $statementName = __METHOD__; $this->dbManager->prepare($statementName, "INSERT INTO folder (folder_name, folder_desc) VALUES ($1, $2) returning folder_pk"); $res = $this->dbManager->execute($statementName, array($folderName, $folderDescription)); $folderRow=$this->dbManager->fetchArray($res); $folderId=$folderRow["folder_pk"]; $this->dbManager->freeResult($res); $this->insertFolderContents($parentFolderId, self::MODE_FOLDER, $folderId); return $folderId; } public function getFolderId($folderName, $parentFolderId=self::TOP_LEVEL) { $statementName = __METHOD__; $this->dbManager->prepare($statementName, "SELECT folder_pk FROM folder, foldercontents fc" ." WHERE folder_name=$1 AND fc.parent_fk=$2 AND fc.foldercontents_mode=$3 AND folder_pk=child_id"); $res = $this->dbManager->execute($statementName, array( $folderName, $parentFolderId, self::MODE_FOLDER)); $rows= $this->dbManager->fetchAll($res); $rootFolder = !empty($rows) ? intval($rows[0]['folder_pk']) : null; $this->dbManager->freeResult($res); return $rootFolder; } public function insertFolderContents($parentId, $foldercontentsMode, $childId) { $statementName = __METHOD__; $this->dbManager->prepare($statementName, "INSERT INTO foldercontents (parent_fk, foldercontents_mode, child_id) VALUES ($1, $2, $3)"); $res = $this->dbManager->execute($statementName, array($parentId, $foldercontentsMode, $childId)); $this->dbManager->freeResult($res); } protected function fixFolderSequence() { $statementName = __METHOD__; $this->dbManager->prepare($statementName, "SELECT setval('folder_folder_pk_seq', (SELECT max(folder_pk) + 1 FROM folder LIMIT 1))"); $res = $this->dbManager->execute($statementName); $this->dbManager->freeResult($res); } /** * @param int $userId * @return Folder|null */ public function getRootFolder($userId) { $statementName = __METHOD__; $this->dbManager->prepare($statementName, "SELECT f.* FROM folder f INNER JOIN users u ON f.folder_pk = u.root_folder_fk WHERE u.user_pk = $1"); $res = $this->dbManager->execute($statementName, array($userId)); $row = $this->dbManager->fetchArray($res); $rootFolder = $row ? new Folder(intval($row['folder_pk']), $row['folder_name'], $row['folder_desc'], intval($row['folder_perm'])) : null; $this->dbManager->freeResult($res); return $rootFolder; } public function getFolderTreeCte($parentId=null) { $parentCondition = $parentId ? 'folder_pk=$1' : 'folder_pk='.self::TOP_LEVEL; return "WITH RECURSIVE folder_tree(folder_pk, parent_fk, folder_name, folder_desc, folder_perm, id_path, name_path, depth, cycle_detected) AS ( SELECT f.folder_pk, fc.parent_fk, f.folder_name, f.folder_desc, f.folder_perm, ARRAY [f.folder_pk] AS id_path, ARRAY [f.folder_name] AS name_path, 0 AS depth, FALSE AS cycle_detected FROM folder f LEFT JOIN foldercontents fc ON fc.foldercontents_mode=".self::MODE_FOLDER." AND f.folder_pk=fc.child_id WHERE $parentCondition UNION ALL SELECT f.folder_pk, fc.parent_fk, f.folder_name, f.folder_desc, f.folder_perm, id_path || f.folder_pk, name_path || f.folder_name, array_length(id_path, 1), f.folder_pk = ANY (id_path) FROM folder f, foldercontents fc, folder_tree ft WHERE f.folder_pk=fc.child_id AND foldercontents_mode=".self::MODE_FOLDER." AND fc.parent_fk = ft.folder_pk AND NOT cycle_detected )"; } public function getFolderStructure($parentId=null) { $statementName = __METHOD__ . ($parentId ? '.relativeToParent' : ''); $parameters = $parentId ? array($parentId) : array(); $this->dbManager->prepare($statementName, $this->getFolderTreeCte($parentId) . " SELECT folder_pk, parent_fk, folder_name, folder_desc, folder_perm, depth FROM folder_tree ORDER BY name_path"); $res = $this->dbManager->execute($statementName, $parameters); $userGroupMap = $this->userDao->getUserGroupMap(Auth::getUserId()); $results = array(); while ($row = $this->dbManager->fetchArray($res)) { $countUploads = $this->countFolderUploads(intval($row['folder_pk']), $userGroupMap); $results[] = array( self::FOLDER_KEY => new Folder( intval($row['folder_pk']), $row['folder_name'], $row['folder_desc'], intval($row['folder_perm'])), self::DEPTH_KEY => $row['depth'], self::REUSE_KEY => $countUploads ); } $this->dbManager->freeResult($res); return $results; } /** * @param int $parentId * @param string[] $userGroupMap map groupId=>groupName * @return array of array(group_id,count,group_name) */ public function countFolderUploads($parentId, $userGroupMap) { $trustGroupIds = array_keys($userGroupMap); $statementName = __METHOD__; $trustedGroups = '{'. implode(',', $trustGroupIds) .'}'; $parameters = array($parentId, $trustedGroups); $this->dbManager->prepare($statementName, " SELECT group_fk group_id,count(*) FROM foldercontents fc INNER JOIN upload u ON u.upload_pk = fc.child_id INNER JOIN upload_clearing uc ON u.upload_pk=uc.upload_fk AND uc.group_fk=ANY($2) WHERE fc.parent_fk = $1 AND fc.foldercontents_mode = ". self::MODE_UPLOAD ." AND u.upload_mode = 104 GROUP BY group_fk "); $res = $this->dbManager->execute($statementName, $parameters); $results = array(); while ($row = $this->dbManager->fetchArray($res)) { $row['group_name'] = $userGroupMap[$row['group_id']]; $results[$row['group_name']] = $row; } $this->dbManager->freeResult($res); return $results; } public function getFolderChildUploads($parentId, $trustGroupId) { $statementName = __METHOD__; $parameters = array($parentId, $trustGroupId); $this->dbManager->prepare($statementName, $sql=" SELECT u.*,uc.*,fc.foldercontents_pk FROM foldercontents fc INNER JOIN upload u ON u.upload_pk = fc.child_id INNER JOIN upload_clearing uc ON u.upload_pk=uc.upload_fk AND uc.group_fk=$2 WHERE fc.parent_fk = $1 AND fc.foldercontents_mode = " .self::MODE_UPLOAD. " AND u.upload_mode = 104 "); $res = $this->dbManager->execute($statementName, $parameters); $results = $this->dbManager->fetchAll($res); $this->dbManager->freeResult($res); return $results; } /** * @param int $parentId * @param int $trustGroupId * @return UploadProgress[] */ public function getFolderUploads($parentId, $trustGroupId=null) { if (empty($trustGroupId)) { $trustGroupId = Auth::getGroupId(); } $results = array(); foreach($this->getFolderChildUploads($parentId, $trustGroupId) as $row) { $results[] = UploadProgress::createFromTable($row); } return $results; } public function createFolder($folderName, $folderDescription, $parentId) { - $folderId = $this->dbManager->insertTableRow("folder", array("folder_name"=>$folderName, "folder_desc"=>$folderDescription), null, 'folder_pk'); + $folderId = $this->dbManager->insertTableRow("folder", array("folder_name"=>$folderName, "user_fk"=>Auth::getUserId(), "folder_desc"=>$folderDescription), null, 'folder_pk'); $this->insertFolderContents($parentId, self::MODE_FOLDER, $folderId); return $folderId; } public function ensureTopLevelFolder() { if (!$this->hasTopLevelFolder()) { $this->dbManager->insertTableRow("folder", array("folder_pk"=>self::TOP_LEVEL, "folder_name"=>"Software Repository", "folder_desc"=>"Top Folder")); $this->insertFolderContents(1,0,0); $this->fixFolderSequence(); } } public function isWithoutReusableFolders($folderStructure) { foreach($folderStructure as $folder) { $posibilities = array_reduce($folder[self::REUSE_KEY], function($sum,$groupInfo){ return $sum+$groupInfo['count'];}, 0); if($posibilities > 0) { return false; } } return true; } protected function isInFolderTree($parentId,$folderId) { $cycle = $this->dbManager->getSingleRow( $this->getFolderTreeCte($parentId) . " SELECT depth FROM folder_tree WHERE folder_pk=$2 LIMIT 1", array($parentId,$folderId), __METHOD__); return !empty($cycle); } protected function getContent($folderContentId) { $content = $this->dbManager->getSingleRow('SELECT * FROM foldercontents WHERE foldercontents_pk=$1', array($folderContentId), __METHOD__.'.getContent' ); if (empty($content)) { throw new \Exception('invalid FolderContentId'); } return $content; } protected function isContentMovable($content, $newParentId) { if ($content['parent_fk'] == $newParentId) { return false; } $newParent = $this->dbManager->getSingleRow('SELECT * FROM folder WHERE folder_pk=$1', array($newParentId), __METHOD__.'.getParent'); if (empty($newParent)) { throw new \Exception('invalid parent folder'); } if($content['foldercontents_mode']==self::MODE_FOLDER) { if ($this->isInFolderTree($content['child_id'],$newParentId)) { throw new \Exception("action would cause a cycle"); } } elseif($content['foldercontents_mode']==self::MODE_UPLOAD) { $uploadId = $content['child_id']; if (!$this->uploadDao->isEditable($uploadId, Auth::getGroupId())) { throw new \Exception('permission to upload denied'); } } return true; } public function moveContent($folderContentId, $newParentId) { $content = $this->getContent($folderContentId); if (!$this->isContentMovable($content, $newParentId)) { return; } $this->dbManager->getSingleRow('UPDATE foldercontents SET parent_fk=$2 WHERE foldercontents_pk=$1', array($folderContentId,$newParentId),__METHOD__.'.updateFolderParent'); } public function copyContent($folderContentId, $newParentId) { $content = $this->getContent($folderContentId); if (!$this->isContentMovable($content, $newParentId)) { return; } $this->insertFolderContents($newParentId, $content['foldercontents_mode'], $content['child_id']); } public function getRemovableContents($folderId) { $sqlChildren = "SELECT child_id,foldercontents_mode FROM foldercontents GROUP BY child_id,foldercontents_mode HAVING count(*)>1 AND bool_or(parent_fk=$1)"; $sql = "SELECT fc.* FROM foldercontents fc,($sqlChildren) chi " . "WHERE fc.child_id=chi.child_id AND fc.foldercontents_mode=chi.foldercontents_mode and fc.parent_fk=$1"; $this->dbManager->prepare($stmt=__METHOD__,$sql); $res = $this->dbManager->execute($stmt,array($folderId)); $contents = array(); while($row=$this->dbManager->fetchArray($res)) { $contents[] = $row['foldercontents_pk']; } $this->dbManager->freeResult($res); return $contents; } protected function isRemovableContent($childId,$mode) { $sql = "SELECT count(parent_fk) FROM foldercontents WHERE child_id=$1 AND foldercontents_mode=$2"; $parentCounter = $this->dbManager->getSingleRow($sql,array($childId,$mode),__METHOD__); return $parentCounter['count']>1; } public function removeContent($folderContentId) { $content = $this->getContent($folderContentId); if($this->isRemovableContent($content['child_id'],$content['foldercontents_mode'])) { $sql = "DELETE FROM foldercontents WHERE foldercontents_pk=$1"; $this->dbManager->getSingleRow($sql,array($folderContentId),__METHOD__); } } public function getFolderChildFolders($folderId) { $results = array(); $stmtFolder = __METHOD__; $sqlFolder = "SELECT foldercontents_pk,foldercontents_mode, folder_name FROM foldercontents,folder " . "WHERE foldercontents.parent_fk=$1 AND foldercontents.child_id=folder.folder_pk" . " AND foldercontents_mode=".self::MODE_FOLDER; $this->dbManager->prepare($stmtFolder, $sqlFolder); $res = $this->dbManager->execute($stmtFolder,array($folderId)); while($row=$this->dbManager->fetchArray($res)) { $results[$row['foldercontents_pk']] = $row; } $this->dbManager->freeResult($res); return $results; } /** * @param int $folderId * @return Folder|null */ public function getFolder($folderId) { $folderRow = $this->dbManager->getSingleRow('SELECT * FROM folder WHERE folder_pk = $1', array($folderId)); if (!$folderRow) { return null; } return new Folder($folderRow['folder_pk'],$folderRow['folder_name'],$folderRow['folder_desc'],$folderRow['folder_perm']); } -} \ No newline at end of file +} diff --git a/src/spdx2/agent_tests/Functional/fo_report.sql b/src/spdx2/agent_tests/Functional/fo_report.sql index df4faa2f..1e4e47c1 100644 --- a/src/spdx2/agent_tests/Functional/fo_report.sql +++ b/src/spdx2/agent_tests/Functional/fo_report.sql @@ -1,589 +1,589 @@ INSERT INTO agent VALUES (1, 'nomos', '2.4.1-ng.695dd8', 'License Scanner', true, NULL, '2015-05-04 11:37:39.12504+02'); INSERT INTO agent VALUES (2, 'delagent', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.477678+02'); INSERT INTO agent VALUES (3, 'maintagent', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.597601+02'); INSERT INTO agent VALUES (4, 'mimetype', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.623748+02'); INSERT INTO agent VALUES (5, 'reportgen', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.62586+02'); INSERT INTO agent VALUES (6, 'adj2nest', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.636537+02'); INSERT INTO agent VALUES (7, 'monkbulk', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.637863+02'); INSERT INTO agent VALUES (8, 'monk', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.642129+02'); INSERT INTO agent VALUES (10, 'pkgagent', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.669964+02'); INSERT INTO agent VALUES (11, 'ecc', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.6724+02'); INSERT INTO agent VALUES (12, 'buckets', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.673072+02'); INSERT INTO agent VALUES (13, 'wget_agent', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.681217+02'); INSERT INTO agent VALUES (14, 'ununpack', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.732657+02'); INSERT INTO agent VALUES (15, 'copyright', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.820557+02'); INSERT INTO agent VALUES (16, 'ninka', '2.4.1-ng.695dd8', '(null)', true, NULL, '2015-05-04 11:42:21.820836+02'); INSERT INTO agent VALUES (17, 'deciderjob', '2.4.1-ng.695dd8', 'deciderjob agent', true, NULL, '2015-05-04 11:42:22.130801+02'); INSERT INTO agent VALUES (18, 'report', '2.4.1-ng.695dd8', 'report agent', true, NULL, '2015-05-04 11:42:22.155375+02'); INSERT INTO agent VALUES (19, 'readmeoss', '2.4.1-ng.695dd8', 'readmeoss agent', true, NULL, '2015-05-04 11:42:22.170878+02'); INSERT INTO agent VALUES (20, 'decider', '2.4.1-ng.695dd8', 'decider agent', true, NULL, '2015-05-04 11:42:22.24854+02'); INSERT INTO agent VALUES (21, 'reuser', '2.4.1-ng.695dd8', 'reuser agent', true, NULL, '2015-05-04 11:42:22.306605+02'); INSERT INTO upload VALUES (1, '', 'ReportTestfiles.tar', 2, 104, '2015-05-04 11:43:14.866898+02', 1, 'ReportTestfiles.tar', 'uploadtree_a', NULL, NULL, 0); INSERT INTO bucketpool VALUES (1, 'GPL Demo bucket pool', 1, 'Y', 'Demonstration of a very simple GPL/non-gpl bucket pool'); INSERT INTO bucket_def VALUES (1, 'GPL Licenses (Demo)', 'orange', 50, 50, 1, 3, '(affero|gpl)', NULL, 'N', 'f'); INSERT INTO bucket_def VALUES (2, 'non-gpl (Demo)', 'yellow', 50, 1000, 1, 99, NULL, NULL, 'N', 'f'); INSERT INTO groups VALUES (1, 'Default User'); INSERT INTO groups VALUES (2, 'fossy'); INSERT INTO mimetype VALUES (1, 'application/gzip'); INSERT INTO mimetype VALUES (2, 'application/x-gzip'); INSERT INTO mimetype VALUES (3, 'application/x-compress'); INSERT INTO mimetype VALUES (4, 'application/x-bzip'); INSERT INTO mimetype VALUES (5, 'application/x-bzip2'); INSERT INTO mimetype VALUES (6, 'application/x-upx'); INSERT INTO mimetype VALUES (7, 'application/pdf'); INSERT INTO mimetype VALUES (8, 'application/x-pdf'); INSERT INTO mimetype VALUES (9, 'application/x-zip'); INSERT INTO mimetype VALUES (10, 'application/zip'); INSERT INTO mimetype VALUES (11, 'application/x-tar'); INSERT INTO mimetype VALUES (12, 'application/x-gtar'); INSERT INTO mimetype VALUES (13, 'application/x-cpio'); INSERT INTO mimetype VALUES (14, 'application/x-rar'); INSERT INTO mimetype VALUES (15, 'application/x-cab'); INSERT INTO mimetype VALUES (16, 'application/x-7z-compressed'); INSERT INTO mimetype VALUES (17, 'application/x-7z-w-compressed'); INSERT INTO mimetype VALUES (18, 'application/x-rpm'); INSERT INTO mimetype VALUES (19, 'application/x-archive'); INSERT INTO mimetype VALUES (20, 'application/x-debian-package'); INSERT INTO mimetype VALUES (21, 'application/x-iso'); INSERT INTO mimetype VALUES (22, 'application/x-iso9660-image'); INSERT INTO mimetype VALUES (23, 'application/x-fat'); INSERT INTO mimetype VALUES (24, 'application/x-ntfs'); INSERT INTO mimetype VALUES (25, 'application/x-ext2'); INSERT INTO mimetype VALUES (26, 'application/x-ext3'); INSERT INTO mimetype VALUES (27, 'application/x-x86_boot'); INSERT INTO mimetype VALUES (28, 'application/x-debian-source'); INSERT INTO mimetype VALUES (29, 'application/x-xz'); INSERT INTO mimetype VALUES (30, 'application/jar'); INSERT INTO mimetype VALUES (31, 'application/x-dosexec'); INSERT INTO pfile VALUES (1, '149FD9DAC3A1FF6AD491F95F49E90BF2', '403C2B25B9B02A2EBB6817C459B37AFC1F9BA3B5', 35328, 11); INSERT INTO pfile VALUES (2, '8F4010C5B689A6EA4A28671FD1907F23', '75E8FBDFAB38D5406BD718711D8FDDDB530CA174', 6880, NULL); INSERT INTO pfile VALUES (3, 'C2047D353D61BCE5D6335CC1C30C1780', '2634F1C5473C7A9E9B9238EC2AAB1FCA468911A8', 6894, NULL); INSERT INTO pfile VALUES (4, 'BE09F57E1E58119F1537439BA545835C', 'FD7D17CFA15074F73F183C086B1983EB9F31781F', 296, NULL); INSERT INTO pfile VALUES (5, '39C379E9C7F5BB524754C4DEF5FEF135', '840B588279248271D93ACA3092AD5F4DC724BDA4', 285, NULL); INSERT INTO pfile VALUES (6, '2702A657B801333C3150BDC8BE642F9B', '798826BF3EB294E5D514ECFA3222CCF09BBCD985', 14554, NULL); INSERT INTO users VALUES (1, 'Default User', 1, 'Default User when nobody is logged in', 'Seed', 'Pass', 0, NULL, 'y', NULL, NULL, 'simple', NULL, NULL, NULL); INSERT INTO users VALUES (2, 'fossy', 1, 'Default Administrator', '14272952581103610285', 'cdd40d0517419e8495a6e40b14369b6a39031581', 10, 'y', 'y', NULL, NULL, 'simple', NULL, NULL, NULL); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (2, 4, 2, 2, 2, 5, 1, '2015-05-04 11:43:18.276425+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (4, 5, 3, 2, 2, 5, 1, '2015-05-04 11:43:18.297719+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (7, 10, 6, 2, 2, 5, 0, '2015-05-04 11:44:10.097161+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (8, 10, 6, 2, 2, 4, 0, '2015-05-04 11:45:11.88761+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (10, 7, 4, 2, 2, 5, 0, '2015-05-04 11:45:30.851906+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (12, 8, 5, 2, 2, 5, 0, '2015-05-04 11:45:34.941938+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (14, 5, 3, 2, 2, 5, 0, '2015-05-04 11:46:26.59626+02'); INSERT INTO clearing_decision (clearing_decision_pk, uploadtree_fk, pfile_fk, user_fk, group_fk, decision_type, scope, date_added) VALUES (16, 4, 2, 2, 2, 5, 0, '2015-05-04 11:47:10.946366+02'); INSERT INTO clearing_decision_event VALUES (1, 2); INSERT INTO clearing_decision_event VALUES (2, 4); INSERT INTO clearing_decision_event VALUES (4, 7); INSERT INTO clearing_decision_event VALUES (3, 7); INSERT INTO clearing_decision_event VALUES (3, 8); INSERT INTO clearing_decision_event VALUES (4, 8); INSERT INTO clearing_decision_event VALUES (5, 10); INSERT INTO clearing_decision_event VALUES (6, 12); INSERT INTO clearing_decision_event VALUES (7, 14); INSERT INTO clearing_decision_event VALUES (8, 16); INSERT INTO clearing_event VALUES (1, 4, 485, false, 2, 2, NULL, 3, '', '', '2015-05-04 11:43:18.276425+02'); INSERT INTO clearing_event VALUES (2, 5, 272, false, 2, 2, NULL, 3, '', '', '2015-05-04 11:43:18.297719+02'); INSERT INTO clearing_event VALUES (3, 10, 561, true, 2, 2, NULL, 1, '', '', '2015-05-04 11:44:07.229472+02'); INSERT INTO clearing_event VALUES (4, 10, 560, false, 2, 2, NULL, 3, '', '', '2015-05-04 11:44:10.097161+02'); INSERT INTO clearing_event VALUES (5, 7, 199, false, 2, 2, NULL, 3, '', '', '2015-05-04 11:45:30.851906+02'); INSERT INTO clearing_event VALUES (6, 8, 199, false, 2, 2, NULL, 3, '', '', '2015-05-04 11:45:34.941938+02'); INSERT INTO clearing_event VALUES (7, 5, 272, false, 2, 2, NULL, 3, 'all Nomos findings are within the Monk findings', '', '2015-05-04 11:46:22.698323+02'); INSERT INTO clearing_event VALUES (8, 4, 485, false, 2, 2, NULL, 3, '', 'Here is an alternative license text.', '2015-05-04 11:47:09.615748+02'); INSERT INTO copyright VALUES (1, 15, 4, 'Copyright: ', '82b9c4a898c9c8e7dd3b2f12c9efe2f1', 'statement', 85, 96); INSERT INTO copyright VALUES (2, 15, 4, 'Copyright 2004 XXX 3dfx Interactive. conspicuously and appropriately publish on each copy of a derivative work"> ', '257e7a16fdea45af00db34b34901297e', 'statement', 98, 212); INSERT INTO copyright VALUES (3, 15, 2, 'Copyright © 1990-2007 Condor Team, Computer Sciences Department, University of Wisconsin-Madison, Madison, WI. All Rights Reserved. For more information contact: Condor Team, Attention: Professor Miron Livny, Dept of Computer Sciences, 1210 W. Dayton St., Madison, WI 53706-1685, (608) 262-0856 or miron@cs.wisc.edu.', '38fed8260a51272cce26cb9a9e8ae150', 'statement', 288, 605); INSERT INTO copyright VALUES (4, 15, 2, 'Copyright (c) 1999 University of Chicago and The University of Southern California. All Rights Reserved.', '838e7addcd532fd109fcf9046b830fcb', 'statement', 6315, 6419); INSERT INTO copyright VALUES (5, 15, 2, 'http://www.condorproject.org/', '7b3bded8d05be4f8f286137d781671c5', 'url', 816, 845); INSERT INTO copyright VALUES (6, 15, 2, 'http://www.condorproject.org/)"', '5f99b6394b68ba3efd6355d001cf5c9c', 'url', 1537, 1568); INSERT INTO copyright VALUES (7, 15, 2, 'http://pages.cs.wisc.edu/~miron/miron.html', '8c35167907ce1778906c09d05ecf2008', 'url', 6096, 6138); INSERT INTO copyright VALUES (8, 15, 2, 'http://www.globus.org/)', '01792705aacafab69309d1a5b10a1ff3', 'url', 6238, 6261); INSERT INTO copyright VALUES (9, 15, 2, 'http://www.gnu.org/software/libc/', '0083c8b416c911ebd402eb58b58d6aee', 'url', 6569, 6602); INSERT INTO copyright VALUES (10, 15, 2, 'miron@cs.wisc.edu', '1102feddb903c81db7bd06a95548f49f', 'email', 587, 604); INSERT INTO copyright VALUES (11, 15, 2, 'condor-admin@cs.wisc.edu', '330bfb156248b5c4a07d7bb14b2e7b86', 'email', 2245, 2269); INSERT INTO copyright VALUES (12, 15, 2, 'miron@cs.wisc.edu', '1102feddb903c81db7bd06a95548f49f', 'email', 6078, 6095); INSERT INTO copyright VALUES (13, 15, 2, 'CONTRIBUTORS', '98f07bc20cb66328be238119df96c490', 'author', 3686, 3698); INSERT INTO copyright VALUES (14, 15, 2, 'CONTRIBUTORS MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS, ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY RIGHT.', 'f024c21e035ed961f01c504644199975', 'author', 3931, 4135); INSERT INTO copyright VALUES (15, 15, 2, 'CONTRIBUTORS SHALL HAVE NO LIABILITY TO LICENSEE OR OTHER PERSONS FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA OR PROFITS, OR BUSINESS INTERRUPTION, HOWEVER CAUSED AND ON ANY THEORY OF CONTRACT, WARRANTY, TORT', '9d35c5020b1a224f65a49c8615821d91', 'author', 4196, 4560); INSERT INTO copyright VALUES (16, 15, 5, 'Copyright: ', '82b9c4a898c9c8e7dd3b2f12c9efe2f1', 'statement', 79, 90); INSERT INTO copyright VALUES (17, 15, 5, 'Copyright 2004 XXX 3dfx Interactive. conspicuously and appropriately publish on each copy of a derivative work"> ', '257e7a16fdea45af00db34b34901297e', 'statement', 92, 206); INSERT INTO copyright VALUES (18, 15, 6, 'Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.', 'b3a0b78c4f3bda49400c03e2dc4af2fe', 'statement', 343, 426); INSERT INTO copyright VALUES (19, 15, 6, 'phk@login.dknet.dk', 'be9a31b6132e46a413774b36859fb540', 'email', 1685, 1703); INSERT INTO copyright VALUES (20, 15, 6, 'andersen@uclibc.org', 'b80a70781d6e6a7bba4953b6ecd2e214', 'email', 2185, 2204); INSERT INTO copyright VALUES (21, 15, 3, 'Copyright (c) 1990-2006 Condor Team, Computer Sciences Department, University of Wisconsin-Madison, Madison, WI. All Rights Reserved. For more information contact: Condor Team, Attention: Professor Miron Livny, Dept of Computer Sciences, 1210 W. Dayton St., Madison, WI 53706-1685, 608) 262-0856 or miron@cs.wisc.edu.', '80b1b708b6c123ebcbab66818e432351', 'statement', 54, 370); INSERT INTO copyright VALUES (23, 15, 3, 'http://www.condorproject.org/', '7b3bded8d05be4f8f286137d781671c5', 'url', 820, 849); INSERT INTO copyright VALUES (24, 15, 3, 'http://www.condorproject.org/)"', '5f99b6394b68ba3efd6355d001cf5c9c', 'url', 1545, 1576); INSERT INTO copyright VALUES (25, 15, 3, 'http://www.cs.wisc.edu/~miron/miron.html', 'a9731964cbb7701ae0191d610f8d2224', 'url', 6363, 6403); INSERT INTO copyright VALUES (26, 15, 3, 'http://www.globus.org/)', '01792705aacafab69309d1a5b10a1ff3', 'url', 6509, 6532); INSERT INTO copyright VALUES (27, 15, 3, 'http://www.gnu.org/software/libc/', '0083c8b416c911ebd402eb58b58d6aee', 'url', 6858, 6891); INSERT INTO copyright VALUES (28, 15, 3, 'miron@cs.wisc.edu', '1102feddb903c81db7bd06a95548f49f', 'email', 352, 369); INSERT INTO copyright VALUES (29, 15, 3, 'condor-admin@cs.wisc.edu', '330bfb156248b5c4a07d7bb14b2e7b86', 'email', 2295, 2319); INSERT INTO copyright VALUES (30, 15, 3, 'miron@cs.wisc.edu', '1102feddb903c81db7bd06a95548f49f', 'email', 6345, 6362); INSERT INTO copyright VALUES (31, 15, 3, 'authority', '873e9c0b50183b613336eea1020f4369', 'author', 570, 579); INSERT INTO copyright VALUES (32, 15, 3, 'Contributors and the University', '1b9da6873af4fafcecb86a7778e976b8', 'author', 730, 761); INSERT INTO copyright VALUES (33, 15, 3, 'CONTRIBUTORS AND THE UNIVERSITY', 'ef6a95f6baea2c6f551161de39c4a67f', 'author', 3826, 3863); INSERT INTO copyright VALUES (34, 15, 3, 'CONTRIBUTORS AND THE UNIVERSITY MAKE NO REPRESENTATION THAT THE', '57d9c9d62a47e75d9f90ba05c82748e5', 'author', 4120, 4183); INSERT INTO copyright VALUES (35, 15, 3, 'CONTRIBUTORS AND ANY OTHER OFFICER', '1cb39133d8d92e45813cd58562660ee1', 'author', 4426, 4460); INSERT INTO copyright_ars VALUES (2, 15, 1, true, NULL, '2015-05-04 11:43:17.244277+02', '2015-05-04 11:43:17.304726+02'); INSERT INTO copyright_decision VALUES (1, 2, 2, 5, '', '', ''); INSERT INTO copyright_decision VALUES (2, 2, 3, 4, '', '', ''); INSERT INTO copyright_decision VALUES (3, 2, 6, 4, '', '', ''); INSERT INTO copyright_decision VALUES (4, 2, 3, 5, '', '', ''); INSERT INTO decider_ars VALUES (5, 20, 1, true, NULL, '2015-05-04 11:43:18.236117+02', '2015-05-04 11:43:18.305526+02'); -INSERT INTO folder VALUES (1, 'Software Repository', 'Top Folder', NULL); +INSERT INTO folder (folder_pk, folder_name, user_fk, folder_desc, folder_perm) VALUES (1, 'Software Repository', 2, 'Top Folder', NULL); INSERT INTO foldercontents VALUES (1, 1, 0, 0); INSERT INTO foldercontents VALUES (2, 1, 2, 1); INSERT INTO group_user_member VALUES (1, 1, 1, 1); INSERT INTO group_user_member VALUES (2, 2, 2, 1); INSERT INTO highlight VALUES ('L ', 867, 71, 3, NULL, NULL); INSERT INTO highlight VALUES ('L ', 234, 34, 3, NULL, NULL); INSERT INTO highlight VALUES ('M ', 234, 5709, 4, 0, 5666); INSERT INTO highlight VALUES ('M0', 0, 1129, 6, 0, 1137); INSERT INTO highlight VALUES ('M+', 1134, 2, 6, 1141, 0); INSERT INTO highlight VALUES ('M0', 1137, 230, 6, 1141, 221); INSERT INTO highlight VALUES ('M+', 1372, 2, 6, 1364, 0); INSERT INTO highlight VALUES ('M0', 1375, 363, 6, 1364, 322); INSERT INTO highlight VALUES ('M+', 1743, 2, 6, 1690, 0); INSERT INTO highlight VALUES ('M0', 1746, 172, 6, 1690, 166); INSERT INTO highlight VALUES ('M+', 1923, 2, 6, 1858, 0); INSERT INTO highlight VALUES ('M0', 1926, 398, 6, 1858, 383); INSERT INTO highlight VALUES ('M+', 2329, 2, 6, 2243, 0); INSERT INTO highlight VALUES ('M0', 2332, 1417, 6, 2243, 1330); INSERT INTO highlight VALUES ('M+', 3754, 2, 6, 3577, 0); INSERT INTO highlight VALUES ('M0', 3757, 608, 6, 3577, 554); INSERT INTO highlight VALUES ('M+', 4370, 2, 6, 4135, 0); INSERT INTO highlight VALUES ('M0', 4373, 695, 6, 4135, 635); INSERT INTO highlight VALUES ('M+', 5073, 2, 6, 4774, 0); INSERT INTO highlight VALUES ('M0', 5076, 568, 6, 4774, 544); INSERT INTO highlight VALUES ('M+', 5649, 2, 6, 5320, 0); INSERT INTO highlight VALUES ('M0', 5652, 755, 6, 5320, 746); INSERT INTO highlight VALUES ('L ', 871, 71, 7, NULL, NULL); INSERT INTO highlight VALUES ('L ', 0, 34, 7, NULL, NULL); INSERT INTO highlight VALUES ('L ', 98, 36, 8, NULL, NULL); INSERT INTO highlight VALUES ('L ', 136, 73, 8, NULL, NULL); INSERT INTO highlight VALUES ('L ', 92, 36, 9, NULL, NULL); INSERT INTO highlight VALUES ('L ', 130, 73, 9, NULL, NULL); INSERT INTO highlight VALUES ('L ', 353, 35, 11, NULL, NULL); INSERT INTO highlight VALUES ('L ', 691, 29, 11, NULL, NULL); INSERT INTO highlight VALUES ('L ', 1639, 269, 10, NULL, NULL); INSERT INTO highlight_keyword VALUES (2, 1619, 14); INSERT INTO highlight_keyword VALUES (2, 1657, 14); INSERT INTO highlight_keyword VALUES (2, 3700, 5); INSERT INTO highlight_keyword VALUES (2, 39, 9); INSERT INTO highlight_keyword VALUES (2, 288, 9); INSERT INTO highlight_keyword VALUES (2, 298, 2); INSERT INTO highlight_keyword VALUES (2, 3664, 9); INSERT INTO highlight_keyword VALUES (2, 3909, 9); INSERT INTO highlight_keyword VALUES (2, 4073, 9); INSERT INTO highlight_keyword VALUES (2, 4174, 9); INSERT INTO highlight_keyword VALUES (2, 6315, 9); INSERT INTO highlight_keyword VALUES (2, 6325, 3); INSERT INTO highlight_keyword VALUES (2, 6504, 2); INSERT INTO highlight_keyword VALUES (2, 4343, 7); INSERT INTO highlight_keyword VALUES (2, 4712, 7); INSERT INTO highlight_keyword VALUES (2, 2665, 6); INSERT INTO highlight_keyword VALUES (2, 4017, 6); INSERT INTO highlight_keyword VALUES (2, 909, 9); INSERT INTO highlight_keyword VALUES (2, 1131, 9); INSERT INTO highlight_keyword VALUES (2, 1420, 9); INSERT INTO highlight_keyword VALUES (2, 2154, 9); INSERT INTO highlight_keyword VALUES (2, 6430, 9); INSERT INTO highlight_keyword VALUES (2, 2429, 5); INSERT INTO highlight_keyword VALUES (2, 3295, 5); INSERT INTO highlight_keyword VALUES (2, 3473, 5); INSERT INTO highlight_keyword VALUES (2, 4154, 10); INSERT INTO highlight_keyword VALUES (2, 4222, 10); INSERT INTO highlight_keyword VALUES (2, 4592, 10); INSERT INTO highlight_keyword VALUES (2, 4962, 10); INSERT INTO highlight_keyword VALUES (2, 53, 6); INSERT INTO highlight_keyword VALUES (2, 248, 6); INSERT INTO highlight_keyword VALUES (2, 1047, 6); INSERT INTO highlight_keyword VALUES (2, 1074, 6); INSERT INTO highlight_keyword VALUES (2, 1227, 6); INSERT INTO highlight_keyword VALUES (2, 2309, 6); INSERT INTO highlight_keyword VALUES (2, 2489, 6); INSERT INTO highlight_keyword VALUES (2, 2695, 6); INSERT INTO highlight_keyword VALUES (2, 2919, 6); INSERT INTO highlight_keyword VALUES (2, 3019, 6); INSERT INTO highlight_keyword VALUES (2, 3073, 6); INSERT INTO highlight_keyword VALUES (2, 3345, 6); INSERT INTO highlight_keyword VALUES (2, 3423, 6); INSERT INTO highlight_keyword VALUES (2, 3547, 6); INSERT INTO highlight_keyword VALUES (2, 4236, 6); INSERT INTO highlight_keyword VALUES (2, 4726, 6); INSERT INTO highlight_keyword VALUES (2, 4852, 6); INSERT INTO highlight_keyword VALUES (2, 4932, 6); INSERT INTO highlight_keyword VALUES (2, 5179, 6); INSERT INTO highlight_keyword VALUES (2, 5293, 6); INSERT INTO highlight_keyword VALUES (2, 5390, 6); INSERT INTO highlight_keyword VALUES (2, 5482, 6); INSERT INTO highlight_keyword VALUES (2, 5497, 6); INSERT INTO highlight_keyword VALUES (2, 5654, 6); INSERT INTO highlight_keyword VALUES (2, 5821, 6); INSERT INTO highlight_keyword VALUES (2, 5935, 6); INSERT INTO highlight_keyword VALUES (2, 2295, 6); INSERT INTO highlight_keyword VALUES (2, 2508, 6); INSERT INTO highlight_keyword VALUES (2, 2688, 6); INSERT INTO highlight_keyword VALUES (2, 2892, 6); INSERT INTO highlight_keyword VALUES (2, 2912, 6); INSERT INTO highlight_keyword VALUES (2, 3109, 6); INSERT INTO highlight_keyword VALUES (2, 3255, 6); INSERT INTO highlight_keyword VALUES (2, 3338, 6); INSERT INTO highlight_keyword VALUES (2, 3540, 6); INSERT INTO highlight_keyword VALUES (2, 4065, 6); INSERT INTO highlight_keyword VALUES (2, 2088, 7); INSERT INTO highlight_keyword VALUES (2, 4816, 7); INSERT INTO highlight_keyword VALUES (2, 6629, 7); INSERT INTO highlight_keyword VALUES (2, 973, 17); INSERT INTO highlight_keyword VALUES (2, 2628, 11); INSERT INTO highlight_keyword VALUES (2, 6528, 11); INSERT INTO highlight_keyword VALUES (2, 1087, 10); INSERT INTO highlight_keyword VALUES (2, 6674, 20); INSERT INTO highlight_keyword VALUES (2, 3734, 7); INSERT INTO highlight_keyword VALUES (2, 3789, 7); INSERT INTO highlight_keyword VALUES (2, 4546, 7); INSERT INTO highlight_keyword VALUES (2, 4379, 13); INSERT INTO highlight_keyword VALUES (3, 1628, 14); INSERT INTO highlight_keyword VALUES (3, 1672, 14); INSERT INTO highlight_keyword VALUES (3, 3865, 5); INSERT INTO highlight_keyword VALUES (3, 54, 9); INSERT INTO highlight_keyword VALUES (3, 708, 9); INSERT INTO highlight_keyword VALUES (3, 3804, 9); INSERT INTO highlight_keyword VALUES (3, 4092, 9); INSERT INTO highlight_keyword VALUES (3, 4293, 9); INSERT INTO highlight_keyword VALUES (3, 4404, 9); INSERT INTO highlight_keyword VALUES (3, 6590, 9); INSERT INTO highlight_keyword VALUES (3, 6600, 3); INSERT INTO highlight_keyword VALUES (3, 6789, 2); INSERT INTO highlight_keyword VALUES (3, 4651, 7); INSERT INTO highlight_keyword VALUES (3, 5056, 7); INSERT INTO highlight_keyword VALUES (3, 2732, 6); INSERT INTO highlight_keyword VALUES (3, 4231, 6); INSERT INTO highlight_keyword VALUES (3, 913, 9); INSERT INTO highlight_keyword VALUES (3, 1137, 9); INSERT INTO highlight_keyword VALUES (3, 1414, 9); INSERT INTO highlight_keyword VALUES (3, 2201, 9); INSERT INTO highlight_keyword VALUES (3, 6711, 9); INSERT INTO highlight_keyword VALUES (3, 2487, 5); INSERT INTO highlight_keyword VALUES (3, 3401, 5); INSERT INTO highlight_keyword VALUES (3, 3597, 5); INSERT INTO highlight_keyword VALUES (3, 4382, 10); INSERT INTO highlight_keyword VALUES (3, 4518, 10); INSERT INTO highlight_keyword VALUES (3, 4924, 10); INSERT INTO highlight_keyword VALUES (3, 5598, 10); INSERT INTO highlight_keyword VALUES (3, 14, 6); INSERT INTO highlight_keyword VALUES (3, 1051, 6); INSERT INTO highlight_keyword VALUES (3, 1072, 6); INSERT INTO highlight_keyword VALUES (3, 1236, 6); INSERT INTO highlight_keyword VALUES (3, 2361, 6); INSERT INTO highlight_keyword VALUES (3, 2550, 6); INSERT INTO highlight_keyword VALUES (3, 2765, 6); INSERT INTO highlight_keyword VALUES (3, 2998, 6); INSERT INTO highlight_keyword VALUES (3, 3104, 6); INSERT INTO highlight_keyword VALUES (3, 3160, 6); INSERT INTO highlight_keyword VALUES (3, 3457, 6); INSERT INTO highlight_keyword VALUES (3, 3541, 6); INSERT INTO highlight_keyword VALUES (3, 3677, 6); INSERT INTO highlight_keyword VALUES (3, 4538, 6); INSERT INTO highlight_keyword VALUES (3, 5230, 6); INSERT INTO highlight_keyword VALUES (3, 5273, 6); INSERT INTO highlight_keyword VALUES (3, 5491, 6); INSERT INTO highlight_keyword VALUES (3, 5612, 6); INSERT INTO highlight_keyword VALUES (3, 5729, 6); INSERT INTO highlight_keyword VALUES (3, 5745, 6); INSERT INTO highlight_keyword VALUES (3, 5908, 6); INSERT INTO highlight_keyword VALUES (3, 6084, 6); INSERT INTO highlight_keyword VALUES (3, 6201, 6); INSERT INTO highlight_keyword VALUES (3, 2347, 6); INSERT INTO highlight_keyword VALUES (3, 2569, 6); INSERT INTO highlight_keyword VALUES (3, 2758, 6); INSERT INTO highlight_keyword VALUES (3, 2971, 6); INSERT INTO highlight_keyword VALUES (3, 2991, 6); INSERT INTO highlight_keyword VALUES (3, 3203, 6); INSERT INTO highlight_keyword VALUES (3, 3361, 6); INSERT INTO highlight_keyword VALUES (3, 3450, 6); INSERT INTO highlight_keyword VALUES (3, 3670, 6); INSERT INTO highlight_keyword VALUES (3, 4285, 6); INSERT INTO highlight_keyword VALUES (3, 2127, 7); INSERT INTO highlight_keyword VALUES (3, 5220, 7); INSERT INTO highlight_keyword VALUES (3, 977, 17); INSERT INTO highlight_keyword VALUES (3, 2695, 11); INSERT INTO highlight_keyword VALUES (3, 6813, 11); INSERT INTO highlight_keyword VALUES (3, 1091, 10); INSERT INTO highlight_keyword VALUES (3, 3899, 7); INSERT INTO highlight_keyword VALUES (3, 3960, 7); INSERT INTO highlight_keyword VALUES (3, 4872, 7); INSERT INTO highlight_keyword VALUES (3, 5297, 7); INSERT INTO highlight_keyword VALUES (3, 4693, 13); INSERT INTO highlight_keyword VALUES (4, 85, 9); INSERT INTO highlight_keyword VALUES (4, 98, 9); INSERT INTO highlight_keyword VALUES (4, 194, 6); INSERT INTO highlight_keyword VALUES (5, 79, 9); INSERT INTO highlight_keyword VALUES (5, 92, 9); INSERT INTO highlight_keyword VALUES (5, 188, 6); INSERT INTO highlight_keyword VALUES (6, 1101, 5); INSERT INTO highlight_keyword VALUES (6, 123, 2); INSERT INTO highlight_keyword VALUES (6, 250, 2); INSERT INTO highlight_keyword VALUES (6, 261, 2); INSERT INTO highlight_keyword VALUES (6, 279, 2); INSERT INTO highlight_keyword VALUES (6, 343, 9); INSERT INTO highlight_keyword VALUES (6, 353, 3); INSERT INTO highlight_keyword VALUES (6, 1300, 2); INSERT INTO highlight_keyword VALUES (6, 1968, 2); INSERT INTO highlight_keyword VALUES (6, 4647, 2); INSERT INTO highlight_keyword VALUES (6, 4682, 3); INSERT INTO highlight_keyword VALUES (6, 4780, 2); INSERT INTO highlight_keyword VALUES (6, 4815, 3); INSERT INTO highlight_keyword VALUES (6, 4913, 2); INSERT INTO highlight_keyword VALUES (6, 4948, 3); INSERT INTO highlight_keyword VALUES (6, 5046, 2); INSERT INTO highlight_keyword VALUES (6, 5081, 3); INSERT INTO highlight_keyword VALUES (6, 5322, 2); INSERT INTO highlight_keyword VALUES (6, 5627, 2); INSERT INTO highlight_keyword VALUES (6, 6890, 2); INSERT INTO highlight_keyword VALUES (6, 6944, 2); INSERT INTO highlight_keyword VALUES (6, 7087, 2); INSERT INTO highlight_keyword VALUES (6, 7133, 2); INSERT INTO highlight_keyword VALUES (6, 7179, 2); INSERT INTO highlight_keyword VALUES (6, 7225, 2); INSERT INTO highlight_keyword VALUES (6, 7335, 2); INSERT INTO highlight_keyword VALUES (6, 7338, 2); INSERT INTO highlight_keyword VALUES (6, 7384, 2); INSERT INTO highlight_keyword VALUES (6, 7459, 2); INSERT INTO highlight_keyword VALUES (6, 7520, 2); INSERT INTO highlight_keyword VALUES (6, 7523, 2); INSERT INTO highlight_keyword VALUES (6, 7609, 2); INSERT INTO highlight_keyword VALUES (6, 7670, 2); INSERT INTO highlight_keyword VALUES (6, 7673, 2); INSERT INTO highlight_keyword VALUES (6, 7759, 2); INSERT INTO highlight_keyword VALUES (6, 7820, 2); INSERT INTO highlight_keyword VALUES (6, 7823, 2); INSERT INTO highlight_keyword VALUES (6, 7909, 2); INSERT INTO highlight_keyword VALUES (6, 7970, 2); INSERT INTO highlight_keyword VALUES (6, 7973, 2); INSERT INTO highlight_keyword VALUES (6, 8026, 2); INSERT INTO highlight_keyword VALUES (6, 8091, 2); INSERT INTO highlight_keyword VALUES (6, 8141, 2); INSERT INTO highlight_keyword VALUES (6, 8179, 2); INSERT INTO highlight_keyword VALUES (6, 8229, 2); INSERT INTO highlight_keyword VALUES (6, 8324, 2); INSERT INTO highlight_keyword VALUES (6, 8374, 2); INSERT INTO highlight_keyword VALUES (6, 8412, 2); INSERT INTO highlight_keyword VALUES (6, 8462, 2); INSERT INTO highlight_keyword VALUES (6, 8557, 2); INSERT INTO highlight_keyword VALUES (6, 8607, 2); INSERT INTO highlight_keyword VALUES (6, 8645, 2); INSERT INTO highlight_keyword VALUES (6, 8695, 2); INSERT INTO highlight_keyword VALUES (6, 8790, 2); INSERT INTO highlight_keyword VALUES (6, 8840, 2); INSERT INTO highlight_keyword VALUES (6, 8878, 2); INSERT INTO highlight_keyword VALUES (6, 8928, 2); INSERT INTO highlight_keyword VALUES (6, 9060, 2); INSERT INTO highlight_keyword VALUES (6, 9112, 2); INSERT INTO highlight_keyword VALUES (6, 9152, 2); INSERT INTO highlight_keyword VALUES (6, 9204, 2); INSERT INTO highlight_keyword VALUES (6, 9256, 2); INSERT INTO highlight_keyword VALUES (6, 9308, 2); INSERT INTO highlight_keyword VALUES (6, 9348, 2); INSERT INTO highlight_keyword VALUES (6, 9400, 2); INSERT INTO highlight_keyword VALUES (6, 9452, 2); INSERT INTO highlight_keyword VALUES (6, 9504, 2); INSERT INTO highlight_keyword VALUES (6, 9545, 2); INSERT INTO highlight_keyword VALUES (6, 9598, 2); INSERT INTO highlight_keyword VALUES (6, 9651, 2); INSERT INTO highlight_keyword VALUES (6, 9704, 2); INSERT INTO highlight_keyword VALUES (6, 9745, 2); INSERT INTO highlight_keyword VALUES (6, 9798, 2); INSERT INTO highlight_keyword VALUES (6, 9924, 2); INSERT INTO highlight_keyword VALUES (6, 9977, 2); INSERT INTO highlight_keyword VALUES (6, 10018, 2); INSERT INTO highlight_keyword VALUES (6, 10071, 2); INSERT INTO highlight_keyword VALUES (6, 10124, 2); INSERT INTO highlight_keyword VALUES (6, 10177, 2); INSERT INTO highlight_keyword VALUES (6, 10218, 2); INSERT INTO highlight_keyword VALUES (6, 10271, 2); INSERT INTO highlight_keyword VALUES (6, 10324, 2); INSERT INTO highlight_keyword VALUES (6, 10377, 2); INSERT INTO highlight_keyword VALUES (6, 10418, 2); INSERT INTO highlight_keyword VALUES (6, 10471, 2); INSERT INTO highlight_keyword VALUES (6, 10524, 2); INSERT INTO highlight_keyword VALUES (6, 10577, 2); INSERT INTO highlight_keyword VALUES (6, 10618, 2); INSERT INTO highlight_keyword VALUES (6, 10671, 2); INSERT INTO highlight_keyword VALUES (6, 10798, 2); INSERT INTO highlight_keyword VALUES (6, 10851, 2); INSERT INTO highlight_keyword VALUES (6, 10892, 2); INSERT INTO highlight_keyword VALUES (6, 10945, 2); INSERT INTO highlight_keyword VALUES (6, 10998, 2); INSERT INTO highlight_keyword VALUES (6, 11051, 2); INSERT INTO highlight_keyword VALUES (6, 11092, 2); INSERT INTO highlight_keyword VALUES (6, 11145, 2); INSERT INTO highlight_keyword VALUES (6, 11198, 2); INSERT INTO highlight_keyword VALUES (6, 11251, 2); INSERT INTO highlight_keyword VALUES (6, 11292, 2); INSERT INTO highlight_keyword VALUES (6, 11345, 2); INSERT INTO highlight_keyword VALUES (6, 11398, 2); INSERT INTO highlight_keyword VALUES (6, 11451, 2); INSERT INTO highlight_keyword VALUES (6, 11492, 2); INSERT INTO highlight_keyword VALUES (6, 11545, 2); INSERT INTO highlight_keyword VALUES (6, 11672, 2); INSERT INTO highlight_keyword VALUES (6, 11725, 2); INSERT INTO highlight_keyword VALUES (6, 11766, 2); INSERT INTO highlight_keyword VALUES (6, 11819, 2); INSERT INTO highlight_keyword VALUES (6, 11872, 2); INSERT INTO highlight_keyword VALUES (6, 11925, 2); INSERT INTO highlight_keyword VALUES (6, 11966, 2); INSERT INTO highlight_keyword VALUES (6, 12019, 2); INSERT INTO highlight_keyword VALUES (6, 12072, 2); INSERT INTO highlight_keyword VALUES (6, 12125, 2); INSERT INTO highlight_keyword VALUES (6, 12166, 2); INSERT INTO highlight_keyword VALUES (6, 12219, 2); INSERT INTO highlight_keyword VALUES (6, 12272, 2); INSERT INTO highlight_keyword VALUES (6, 12325, 2); INSERT INTO highlight_keyword VALUES (6, 12366, 2); INSERT INTO highlight_keyword VALUES (6, 12419, 2); INSERT INTO highlight_keyword VALUES (6, 12515, 2); INSERT INTO highlight_keyword VALUES (6, 704, 6); INSERT INTO highlight_keyword VALUES (6, 474, 5); INSERT INTO highlight_keyword VALUES (6, 680, 5); INSERT INTO highlight_keyword VALUES (6, 433, 6); INSERT INTO highlight_keyword VALUES (6, 664, 6); INSERT INTO highlight_keyword VALUES (6, 1623, 6); INSERT INTO highlight_keyword VALUES (6, 1653, 6); INSERT INTO highlight_keyword VALUES (6, 3019, 7); INSERT INTO highlight_keyword VALUES (6, 1138, 7); INSERT INTO job VALUES (1, '2015-05-04 11:43:14.909163+02', 0, NULL, 'ReportTestfiles.tar', 1, NULL, 2, 2); INSERT INTO jobqueue VALUES (1, 1, 'ununpack', '1', '2015-05-04 11:43:14.952183+02', '2015-05-04 11:43:16.129263+02', 'Completed', 1, NULL, 10, NULL, NULL, NULL, NULL); INSERT INTO jobqueue VALUES (2, 1, 'adj2nest', '1', '2015-05-04 11:43:16.154304+02', '2015-05-04 11:43:16.167857+02', 'Completed', 1, NULL, 10, NULL, NULL, NULL, NULL); INSERT INTO jobqueue VALUES (3, 1, 'copyright', '1', '2015-05-04 11:43:17.209319+02', '2015-05-04 11:43:17.317435+02', 'Completed', 1, NULL, 5, NULL, NULL, NULL, NULL); INSERT INTO jobqueue VALUES (4, 1, 'monk', '1', '2015-05-04 11:43:17.19792+02', '2015-05-04 11:43:17.864866+02', 'Completed', 1, NULL, 5, NULL, NULL, NULL, NULL); INSERT INTO jobqueue VALUES (5, 1, 'nomos', '1', '2015-05-04 11:43:17.205995+02', '2015-05-04 11:43:18.096835+02', 'Completed', 1, NULL, 5, NULL, NULL, NULL, NULL); INSERT INTO jobqueue VALUES (6, 1, 'decider', '1', '2015-05-04 11:43:18.233253+02', '2015-05-04 11:43:19.307912+02', 'Completed', 1, NULL, 2, NULL, NULL, NULL, '-r1'); INSERT INTO jobqueue VALUES (7, 1, 'report', '1', '2015-05-04 11:53:18.233253+02', NULL, '', 0, NULL, 2, NULL, NULL, NULL, NULL); INSERT INTO jobdepends VALUES (2, 1); INSERT INTO jobdepends VALUES (3, 2); INSERT INTO jobdepends VALUES (4, 2); INSERT INTO jobdepends VALUES (5, 2); INSERT INTO jobdepends VALUES (6, 2); INSERT INTO jobdepends VALUES (6, 5); INSERT INTO jobdepends VALUES (6, 4); INSERT INTO jobdepends VALUES (6, 2); INSERT INTO license_file VALUES (1, NULL, 8, NULL, '2015-05-04 11:43:17.700032+02', 6, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (2, NULL, 8, NULL, '2015-05-04 11:43:17.703617+02', 4, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (3, 485, 1, NULL, '2015-05-04 11:43:17.711948+02', 2, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (4, 485, 8, 100, '2015-05-04 11:43:17.816367+02', 2, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (5, NULL, 8, NULL, '2015-05-04 11:43:17.835671+02', 5, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (6, 272, 8, 98, '2015-05-04 11:43:17.850531+02', 3, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (7, 272, 1, NULL, '2015-05-04 11:43:17.957299+02', 3, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (8, 199, 1, NULL, '2015-05-04 11:43:17.997061+02', 4, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (9, 199, 1, NULL, '2015-05-04 11:43:18.014822+02', 5, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (10, 560, 1, NULL, '2015-05-04 11:43:18.064022+02', 6, 1, NULL, NULL, NULL, NULL); INSERT INTO license_file VALUES (11, 561, 1, NULL, '2015-05-04 11:43:18.066447+02', 6, 1, NULL, NULL, NULL, NULL); INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, rf_url, rf_add_date, rf_copyleft, "rf_OSIapproved", rf_fullname, "rf_FSFfree", "rf_GPLv2compatible", "rf_GPLv3compatible", rf_notes, "rf_Fedora", marydone, rf_active, rf_text_updatable, rf_md5, rf_detector_type, rf_source) VALUES (485, 'lic A', 'Text of license A.', 'http://www.opensource.org', NULL, NULL, NULL, 'License A', NULL, NULL, NULL, '', NULL, false, false, false, 'eb59014579b4dda6991d5e9838506749', 1, NULL); INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, rf_url, rf_add_date, rf_copyleft, "rf_OSIapproved", rf_fullname, "rf_FSFfree", "rf_GPLv2compatible", "rf_GPLv3compatible", rf_notes, "rf_Fedora", marydone, rf_active, rf_text_updatable, rf_md5, rf_detector_type, rf_source) VALUES (272, 'lic B', 'License by Nomos.', NULL, NULL, NULL, NULL, 'License B', NULL, NULL, NULL, NULL, NULL, false, true, false, NULL, 2, NULL); INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, rf_url, rf_add_date, rf_copyleft, "rf_OSIapproved", rf_fullname, "rf_FSFfree", "rf_GPLv2compatible", "rf_GPLv3compatible", rf_notes, "rf_Fedora", marydone, rf_active, rf_text_updatable, rf_md5, rf_detector_type, rf_source) VALUES (199, 'lic C', 'License by Nomos and new line.', NULL, NULL, NULL, NULL, 'License C', NULL, NULL, NULL, NULL, NULL, false, true, false, NULL, 2, NULL); INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, rf_url, rf_add_date, rf_copyleft, "rf_OSIapproved", rf_fullname, "rf_FSFfree", "rf_GPLv2compatible", "rf_GPLv3compatible", rf_notes, "rf_Fedora", marydone, rf_active, rf_text_updatable, rf_md5, rf_detector_type, rf_source) VALUES (560, 'lic Cpp', 'License by Nomos plus plus.', NULL, NULL, NULL, NULL, 'License Cpp', NULL, NULL, NULL, NULL, NULL, false, true, false, NULL, 2, NULL); INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, rf_url, rf_add_date, rf_copyleft, "rf_OSIapproved", rf_fullname, "rf_FSFfree", "rf_GPLv2compatible", "rf_GPLv3compatible", rf_notes, "rf_Fedora", marydone, rf_active, rf_text_updatable, rf_md5, rf_detector_type, rf_source) VALUES (561, 'lic D', 'License by Nomos.', NULL, NULL, NULL, NULL, 'License D', NULL, NULL, NULL, NULL, NULL, false, true, false, NULL, 2, NULL); INSERT INTO monk_ars VALUES (4, 8, 1, true, NULL, '2015-05-04 11:43:17.619778+02', '2015-05-04 11:43:17.863761+02'); INSERT INTO nomos_ars VALUES (3, 1, 1, true, NULL, '2015-05-04 11:43:17.251076+02', '2015-05-04 11:43:18.095804+02'); INSERT INTO perm_upload VALUES (1, 10, 1, 2); INSERT INTO sysconfig VALUES (1, 'SupportEmailLabel', 'Support', 'Support Email Label', 2, 'Support', 1, 'e.g. "Support"
Text that the user clicks on to create a new support email. This new email will be preaddressed to this support email address and subject. HTML is ok.', ''); INSERT INTO sysconfig VALUES (2, 'SupportEmailAddr', NULL, 'Support Email Address', 2, 'Support', 2, 'e.g. "support@mycompany.com"
Individual or group email address to those providing FOSSology support.', 'check_email_address'); INSERT INTO sysconfig VALUES (3, 'SupportEmailSubject', 'FOSSology Support', 'Support Email Subject line', 2, 'Support', 3, 'e.g. "fossology support"
Subject line to use on support email.', ''); INSERT INTO sysconfig VALUES (4, 'BannerMsg', NULL, 'Banner message', 3, 'Banner', 1, 'This is message will be displayed on every page with a banner. HTML is ok.', ''); INSERT INTO sysconfig VALUES (5, 'LogoImage', NULL, 'Logo Image URL', 2, 'Logo', 1, 'e.g. "http://mycompany.com/images/companylogo.png" or "images/mylogo.png"
This image replaces the fossology project logo. Image is constrained to 150px wide. 80-100px high is a good target. If you change this URL, you MUST also enter a logo URL.', 'check_logo_image_url'); INSERT INTO sysconfig VALUES (6, 'LogoLink', NULL, 'Logo URL', 2, 'Logo', 2, 'e.g. "http://mycompany.com/fossology"
URL a person goes to when they click on the logo. If you change the Logo URL, you MUST also enter a Logo Image.', 'check_logo_url'); INSERT INTO sysconfig VALUES (7, 'FOSSologyURL', 'vagrant-VirtualBox/repo/', 'FOSSology URL', 2, 'URL', 1, 'URL of this FOSSology server, e.g. vagrant-VirtualBox/repo/', 'check_fossology_url'); INSERT INTO sysconfig VALUES (8, 'NomostListNum', '2200', 'Number of Nomost List', 2, 'Number', 4, 'For the Nomos List/Nomost List Download, you can set the number of lines to list/download. Default 2200.', NULL); INSERT INTO sysconfig VALUES (9, 'ShowJobsAutoRefresh', '10', 'ShowJobs Auto Refresh Time', 2, 'Number', NULL, 'No of seconds to refresh ShowJobs', NULL); INSERT INTO sysconfig VALUES (10, 'Release', '2.6.3.1', 'Release', 2, 'Release', NULL, '', NULL); INSERT INTO ununpack_ars VALUES (1, 14, 1, true, NULL, '2015-05-04 11:43:15.048687+02', '2015-05-04 11:43:15.1256+02'); INSERT INTO upload_clearing VALUES (1, 2, 1, 2, 1, NULL); INSERT INTO upload_clearing_license VALUES (1, 2, 199); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (7, 6, 6, 1, 4, 33188, 4, 5, 'test1.dtd'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (8, 6, 6, 1, 5, 33188, 6, 7, 'test2.dtd'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (6, 1, 2, 1, 0, 536888320, 3, 8, '3DFX'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (10, 9, 9, 1, 6, 33188, 10, 11, 'hash_md5prime.c'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (9, 1, 2, 1, 0, 536888320, 9, 12, 'Beerware'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (4, 3, 3, 1, 2, 33188, 14, 15, 'Condor-1.0'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (5, 3, 3, 1, 3, 33188, 16, 17, 'condor-1.1'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (3, 1, 2, 1, 0, 536888320, 13, 18, 'Condor'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (2, 1, 1, 1, 0, 805323776, 2, 19, 'artifact.dir'); INSERT INTO uploadtree_a (uploadtree_pk,realparent,parent,upload_fk,pfile_fk,ufile_mode,lft,rgt,ufile_name) VALUES (1, NULL, NULL, 1, 1, 536904704, 1, 20, 'ReportTestfiles.tar'); diff --git a/src/www/ui/core-schema.dat b/src/www/ui/core-schema.dat index f4cb263a..7b49b9fb 100644 --- a/src/www/ui/core-schema.dat +++ b/src/www/ui/core-schema.dat @@ -1,1845 +1,1849 @@