pm_data_structures.c

Go to the documentation of this file.
00001 /*************************************************** */
00002 /* Rule Set Based Access Control                     */
00003 /* Implementation of PM data structures              */
00004 /* Author and (c) 1999-2009: Amon Ott <ao@rsbac.org> */
00005 /*                                                   */
00006 /* Last modified: 09/Feb/2005                        */
00007 /*************************************************** */
00008 
00009 #include <linux/types.h>
00010 #include <linux/sched.h>
00011 #include <linux/fs.h>
00012 #include <asm/uaccess.h>
00013 #include <linux/file.h>
00014 #include <linux/vmalloc.h>
00015 #include <linux/init.h>
00016 #include <rsbac/types.h>
00017 #include <rsbac/pm_types.h>
00018 #include <rsbac/pm_data_structures.h>
00019 #include <rsbac/getname.h>
00020 #include <rsbac/pm_getname.h>
00021 #include <rsbac/error.h>
00022 #include <rsbac/helpers.h>
00023 #include <rsbac/fs.h>
00024 #include <rsbac/adf.h>
00025 #include <rsbac/adf_main.h>
00026 #include <rsbac/debug.h>
00027 #include <rsbac/proc_fs.h>
00028 #include <rsbac/rkmem.h>
00029 #include <rsbac/lists.h>
00030 #include <linux/string.h>
00031 
00032 /************************************************************************** */
00033 /*                          Global Variables                                */
00034 /************************************************************************** */
00035 
00036 /* The following global variables are needed for access to PM data.         */
00037 
00038 static rsbac_list_handle_t task_set_handle = NULL;
00039 static rsbac_list_handle_t tp_set_handle = NULL;
00040 static rsbac_list_handle_t ru_set_handle = NULL;
00041 static rsbac_list_handle_t pp_set_handle = NULL;
00042 static rsbac_list_handle_t in_pp_set_handle = NULL;
00043 static rsbac_list_handle_t out_pp_set_handle = NULL;
00044 
00045 static rsbac_list_handle_t task_handle = NULL;
00046 static rsbac_list_handle_t class_handle = NULL;
00047 static rsbac_list_handle_t na_handle = NULL;
00048 static rsbac_list_handle_t cs_handle = NULL;
00049 static rsbac_list_handle_t tp_handle = NULL;
00050 static rsbac_list_handle_t pp_handle = NULL;
00051 static rsbac_list_handle_t tkt_handle = NULL;
00052 
00053 /**************************************************/
00054 /*       Declarations of external functions       */
00055 /**************************************************/
00056 
00057 int sys_write(u_int,char *, u_int);
00058 
00059 /**************************************************/
00060 /*       Declarations of internal functions       */
00061 /**************************************************/
00062 
00063 /* As some function use later defined functions, we declare those here.   */
00064 
00065 /************************************************* */
00066 /*               Internal Help functions           */
00067 /************************************************* */
00068 
00069 
00070 /************************************************* */
00071 /*               proc functions                    */
00072 /************************************************* */
00073 
00074 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
00075 static int
00076 stats_pm_proc_info(char *buffer, char **start, off_t offset, int length)
00077 {
00078     u_int len = 0;
00079     off_t pos   = 0;
00080     off_t begin = 0;
00081 
00082     u_long                                   tmp_count;
00083     u_long                                   tmp_member_count;
00084     u_long                                   all_set_count = 0;
00085     u_long                                   all_member_count = 0;
00086     u_long                               all_count = 0;
00087 
00088 #if !defined(CONFIG_RSBAC_MAINT)
00089     union rsbac_target_id_t       rsbac_target_id;
00090     union rsbac_attribute_value_t rsbac_attribute_value;
00091 #endif
00092 
00093     if (!rsbac_is_initialized())
00094       {
00095 #ifdef CONFIG_RSBAC_RMSG
00096         rsbac_printk(KERN_WARNING "stats_pm_proc_info(): RSBAC not initialized\n");
00097 #endif
00098 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
00099         if (!rsbac_nosyslog)
00100 #endif
00101         printk(KERN_WARNING "stats_pm_proc_info(): RSBAC not initialized\n");
00102         return(-RSBAC_ENOTINITIALIZED);
00103       }
00104 #if !defined(CONFIG_RSBAC_MAINT)
00105 #ifdef CONFIG_RSBAC_DEBUG
00106     if (rsbac_debug_aef_pm)
00107       {
00108 #ifdef CONFIG_RSBAC_RMSG
00109         rsbac_printk(KERN_DEBUG "stats_pm_proc_info(): calling ADF\n");
00110 #endif
00111 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
00112         if (!rsbac_nosyslog)
00113 #endif
00114         printk(KERN_DEBUG "stats_pm_proc_info(): calling ADF\n");
00115       }
00116 #endif
00117     rsbac_target_id.scd = ST_rsbac;
00118     rsbac_attribute_value.dummy = 0;
00119     if (!rsbac_adf_request(R_GET_STATUS_DATA,
00120                            current->pid,
00121                            T_SCD,
00122                            rsbac_target_id,
00123                            A_none,
00124                            rsbac_attribute_value))
00125       {
00126 #if defined(CONFIG_RSBAC_SOFTMODE)
00127         if(!rsbac_softmode)
00128 #endif
00129           return -EPERM;
00130       }
00131 #endif
00132 
00133     len += sprintf(buffer, "PM Status\n---------\n");
00134 
00135 /****************/
00136 /* Helper lists */
00137 /****************/
00138 
00139     tmp_count = rsbac_list_lol_count(task_set_handle);
00140     tmp_member_count = rsbac_list_lol_all_subcount(task_set_handle);
00141     len += sprintf(buffer + len, "%lu task-set-items, sum of %lu members\n",
00142                   tmp_count, tmp_member_count);
00143     pos = begin + len;
00144     if (pos < offset)
00145       {
00146         len = 0;
00147         begin = pos;
00148       }
00149     if (pos > offset+length)
00150       goto out;
00151     all_set_count += tmp_count;
00152     all_member_count += tmp_member_count;
00153 
00154     tmp_count = rsbac_list_lol_count(tp_set_handle);
00155     tmp_member_count = rsbac_list_lol_all_subcount(tp_set_handle);
00156     len += sprintf(buffer + len, "%lu tp-set-items, sum of %lu members\n",
00157                   tmp_count, tmp_member_count);
00158     pos = begin + len;
00159     if (pos < offset)
00160       {
00161         len = 0;
00162         begin = pos;
00163       }
00164     if (pos > offset+length)
00165       goto out;
00166     all_set_count += tmp_count;
00167     all_member_count += tmp_member_count;
00168 
00169     tmp_count = rsbac_list_lol_count(ru_set_handle);
00170     tmp_member_count = rsbac_list_lol_all_subcount(ru_set_handle);
00171     len += sprintf(buffer + len, "%lu ru-set-items, sum of %lu members\n",
00172                   tmp_count, tmp_member_count);
00173     pos = begin + len;
00174     if (pos < offset)
00175       {
00176         len = 0;
00177         begin = pos;
00178       }
00179     if (pos > offset+length)
00180       goto out;
00181     all_set_count += tmp_count;
00182     all_member_count += tmp_member_count;
00183 
00184     tmp_count = rsbac_list_lol_count(pp_set_handle);
00185     tmp_member_count = rsbac_list_lol_all_subcount(pp_set_handle);
00186     len += sprintf(buffer + len, "%lu pp-set-items, sum of %lu members\n",
00187                   tmp_count, tmp_member_count);
00188     pos = begin + len;
00189     if (pos < offset)
00190       {
00191         len = 0;
00192         begin = pos;
00193       }
00194     if (pos > offset+length)
00195       goto out;
00196     all_set_count += tmp_count;
00197     all_member_count += tmp_member_count;
00198 
00199     tmp_count = rsbac_list_lol_count(in_pp_set_handle);
00200     tmp_member_count = rsbac_list_lol_all_subcount(in_pp_set_handle);
00201     len += sprintf(buffer + len, "%lu in_pp-set-items, sum of %lu members\n",
00202                   tmp_count, tmp_member_count);
00203     pos = begin + len;
00204     if (pos < offset)
00205       {
00206         len = 0;
00207         begin = pos;
00208       }
00209     if (pos > offset+length)
00210       goto out;
00211     all_set_count += tmp_count;
00212     all_member_count += tmp_member_count;
00213 
00214     tmp_count = rsbac_list_lol_count(out_pp_set_handle);
00215     tmp_member_count = rsbac_list_lol_all_subcount(out_pp_set_handle);
00216     len += sprintf(buffer + len, "%lu out_pp-set-items, sum of %lu members\n",
00217                   tmp_count, tmp_member_count);
00218     pos = begin + len;
00219     if (pos < offset)
00220       {
00221         len = 0;
00222         begin = pos;
00223       }
00224     if (pos > offset+length)
00225       goto out;
00226     all_set_count += tmp_count;
00227     all_member_count += tmp_member_count;
00228 
00229     len += sprintf(buffer + len, "Total of %lu registered rsbac-pm-set-items, %lu members\n",
00230                  all_set_count, all_member_count);
00231 
00232 /**************/
00233 /* Main lists */
00234 /**************/
00235 
00236     tmp_count = rsbac_list_count(task_handle);
00237     len += sprintf(buffer + len, "%lu task-items\n",
00238                    tmp_count);
00239     pos = begin + len;
00240     if (pos < offset)
00241       {
00242         len = 0;
00243         begin = pos;
00244       }
00245     if (pos > offset+length)
00246       goto out;
00247     all_count += tmp_count;
00248 
00249     tmp_count = rsbac_list_count(class_handle);
00250     len += sprintf(buffer + len, "%lu class-items\n",
00251                    tmp_count);
00252     pos = begin + len;
00253     if (pos < offset)
00254       {
00255         len = 0;
00256         begin = pos;
00257       }
00258     if (pos > offset+length)
00259       goto out;
00260     all_count += tmp_count;
00261 
00262     tmp_count = rsbac_list_count(na_handle);
00263     len += sprintf(buffer + len, "%lu necessary access items\n",
00264                    tmp_count);
00265     pos = begin + len;
00266     if (pos < offset)
00267       {
00268         len = 0;
00269         begin = pos;
00270       }
00271     if (pos > offset+length)
00272       goto out;
00273     all_count += tmp_count;
00274 
00275     tmp_count = rsbac_list_count(cs_handle);
00276     len += sprintf(buffer + len, "%lu consent items\n",
00277                    tmp_count);
00278     pos = begin + len;
00279     if (pos < offset)
00280       {
00281         len = 0;
00282         begin = pos;
00283       }
00284     if (pos > offset+length)
00285       goto out;
00286     all_count += tmp_count;
00287 
00288     tmp_count = rsbac_list_count(tp_handle);
00289     len += sprintf(buffer + len, "%lu tp items\n",
00290                    tmp_count);
00291     pos = begin + len;
00292     if (pos < offset)
00293       {
00294         len = 0;
00295         begin = pos;
00296       }
00297     if (pos > offset+length)
00298       goto out;
00299     all_count += tmp_count;
00300 
00301     tmp_count = rsbac_list_count(pp_handle);
00302     len += sprintf(buffer + len, "%lu purpose items\n",
00303                    tmp_count);
00304     pos = begin + len;
00305     if (pos < offset)
00306       {
00307         len = 0;
00308         begin = pos;
00309       }
00310     if (pos > offset+length)
00311       goto out;
00312     all_count += tmp_count;
00313 
00314     tmp_count = rsbac_list_count(tkt_handle);
00315     len += sprintf(buffer + len, "%lu tkt items\n",
00316                    tmp_count);
00317     pos = begin + len;
00318     if (pos < offset)
00319       {
00320         len = 0;
00321         begin = pos;
00322       }
00323     if (pos > offset+length)
00324       goto out;
00325     all_count += tmp_count;
00326 
00327     len += sprintf(buffer + len, "Total of %lu registered rsbac-pm-items\n",
00328                  all_count);
00329     pos = begin + len;
00330     if (pos < offset)
00331       {
00332         len = 0;
00333         begin = pos;
00334       }
00335 
00336 out:
00337   *start = buffer + (offset - begin);
00338   len -= (offset - begin);
00339   
00340   if (len > length)
00341     len = length;
00342   return len;
00343 }
00344 
00345 /* list_proc_read() */
00346 /* Generic readable list generation function */
00347 static int pm_list_proc_read(char *buffer, char **start, off_t offset,
00348   int length, int *eof, void *data)
00349   {
00350     int len = 0;
00351     off_t pos   = 0;
00352     off_t begin = 0;
00353     long            count;
00354     long            subcount;
00355     u_long          i,j;
00356     enum rsbac_pm_list_t list;
00357 
00358     if (!rsbac_is_initialized())
00359       return (-ENOSYS);
00360     list = (enum rsbac_pm_all_list_t) data;
00361 
00362 #if !defined(CONFIG_RSBAC_MAINT)
00363     /* access control */
00364 #if defined(CONFIG_RSBAC_SWITCH)
00365     if(rsbac_switch_pm)
00366 #endif
00367       {
00368         int error;
00369         union  rsbac_target_id_t         tid;
00370         union  rsbac_attribute_value_t   attr_val;
00371 
00372         rsbac_get_owner(&tid.user);
00373         error = rsbac_get_attr(PM,T_USER,tid,A_pm_role,&attr_val,TRUE);
00374         if (error)
00375           {
00376             char * tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
00377 
00378             if(tmp)
00379               {
00380                 get_error_name(tmp,error);
00381 #ifdef CONFIG_RSBAC_RMSG
00382                 rsbac_printk(KERN_WARNING
00383                        "pm_list_proc_read(): rsbac_get_attr() for pm_role returned error %s",
00384                        tmp);
00385 #endif
00386 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
00387                 if (!rsbac_nosyslog)
00388 #endif
00389                 printk(KERN_WARNING
00390                        "pm_list_proc_read(): rsbac_get_attr() for pm_role returned error %s",
00391                        tmp);
00392                 rsbac_kfree(tmp);
00393               }
00394             return(error);  /* something weird happened */
00395           }
00396         if(   (attr_val.pm_role != PR_security_officer)
00397            && (attr_val.pm_role != PR_data_protection_officer)
00398            && (attr_val.pm_role != PR_tp_manager))
00399           {
00400             char * tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
00401 
00402             if(tmp)
00403               {
00404                 get_pm_all_list_name(tmp, list);
00405 #ifdef CONFIG_RSBAC_RMSG
00406                 rsbac_printk(KERN_WARNING
00407                        "pm_list_proc_read(): access to list %s denied\n",
00408                        tmp);
00409 #endif
00410 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
00411                 if (!rsbac_nosyslog)
00412 #endif
00413                 printk(KERN_WARNING
00414                        "pm_list_proc_read(): access to list %s denied\n",
00415                        tmp);
00416                 rsbac_kfree(tmp);
00417               }
00418 #if defined(CONFIG_RSBAC_SOFTMODE)
00419             if(!rsbac_softmode)
00420 #endif
00421               return(-EPERM);
00422           }
00423         if(   (attr_val.pm_role == PR_tp_manager)
00424            && (list != PA_tp))
00425           {
00426 #ifdef CONFIG_RSBAC_RMSG
00427             rsbac_printk(KERN_WARNING
00428                    "pm_list_proc_read(): access to list tp denied\n");
00429 #endif
00430 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
00431             if (!rsbac_nosyslog)
00432 #endif
00433             printk(KERN_WARNING
00434                    "pm_list_proc_read(): access to list tp denied\n");
00435 #if defined(CONFIG_RSBAC_SOFTMODE)
00436             if(!rsbac_softmode)
00437 #endif
00438               return(-EPERM);
00439           }
00440       }
00441 #endif /* !MAINT */
00442 
00443     switch(list)
00444       {
00445         case PA_task_set:
00446           {
00447             rsbac_pm_task_set_id_t * set_array;
00448             rsbac_pm_task_id_t     * member_array;
00449 
00450             count = rsbac_list_lol_get_all_desc(task_set_handle, (void **) &set_array);
00451             if(count < 0)
00452               {
00453                 return count;
00454               }
00455             len += sprintf(buffer + len, "task-set\tmembers\n");
00456             for(i=0; i<count; i++)
00457               {
00458                 len += sprintf(buffer + len, "%u\t\t",
00459                                set_array[i]);
00460                 pos = begin + len;
00461                 if (pos < offset)
00462                   {
00463                     len = 0;
00464                     begin = pos;
00465                   }
00466                 if (pos > offset+length)
00467                   {
00468                     rsbac_vfree(set_array);
00469                     goto out;
00470                   }
00471 
00472                 subcount = rsbac_list_lol_get_all_subdesc(task_set_handle,
00473                                                           &set_array[i],
00474                                                           (void **) &member_array);
00475                 if(subcount < 0)
00476                   {
00477                     rsbac_vfree(set_array);
00478                     goto out;
00479                   }
00480                 for(j=0; j<subcount; j++)
00481                   {
00482                     len += sprintf(buffer + len, "%u ",
00483                                    member_array[j]);
00484                     pos = begin + len;
00485                     if (pos < offset)
00486                       {
00487                         len = 0;
00488                         begin = pos;
00489                       }
00490                     if (pos > offset+length)
00491                       {
00492                         rsbac_vfree(set_array);
00493                         rsbac_vfree(member_array);
00494                         goto out;
00495                       }
00496                   };
00497                 if(subcount > 0)
00498                   rsbac_vfree(member_array);
00499                 len += sprintf(buffer + len, "\n");
00500                 pos = begin + len;
00501                 if (pos < offset)
00502                   {
00503                     len = 0;
00504                     begin = pos;
00505                   }
00506                 if (pos > offset+length)
00507                   {
00508                     rsbac_vfree(set_array);
00509                     goto out;
00510                   }
00511               };
00512             if(count > 0)
00513               rsbac_vfree(set_array);
00514             break;
00515           }
00516 
00517         case PA_tp_set:
00518           {
00519             rsbac_pm_tp_set_id_t * set_array;
00520             rsbac_pm_tp_id_t     * member_array;
00521 
00522             count = rsbac_list_lol_get_all_desc(tp_set_handle, (void **) &set_array);
00523             if(count < 0)
00524               {
00525                 return count;
00526               }
00527             len += sprintf(buffer + len, "tp-set\t\tmembers\n");
00528             for(i=0; i<count; i++)
00529               {
00530                 len += sprintf(buffer + len, "%u\t\t",
00531                                set_array[i]);
00532                 pos = begin + len;
00533                 if (pos < offset)
00534                   {
00535                     len = 0;
00536                     begin = pos;
00537                   }
00538                 if (pos > offset+length)
00539                   {
00540                     rsbac_vfree(set_array);
00541                     goto out;
00542                   }
00543 
00544                 subcount = rsbac_list_lol_get_all_subdesc(tp_set_handle,
00545                                                           &set_array[i],
00546                                                           (void **) &member_array);
00547                 if(subcount < 0)
00548                   {
00549                     rsbac_vfree(set_array);
00550                     goto out;
00551                   }
00552                 for(j=0; j<subcount; j++)
00553                   {
00554                     len += sprintf(buffer + len, "%u ",
00555                                    member_array[j]);
00556                     pos = begin + len;
00557                     if (pos < offset)
00558                       {
00559                         len = 0;
00560                         begin = pos;
00561                       }
00562                     if (pos > offset+length)
00563                       {
00564                         rsbac_vfree(set_array);
00565                         rsbac_vfree(member_array);
00566                         goto out;
00567                       }
00568                   };
00569                 if(subcount > 0)
00570                   rsbac_vfree(member_array);
00571                 len += sprintf(buffer + len, "\n");
00572                 pos = begin + len;
00573                 if (pos < offset)
00574                   {
00575                     len = 0;
00576                     begin = pos;
00577                   }
00578                 if (pos > offset+length)
00579                   {
00580                     rsbac_vfree(set_array);
00581                     goto out;
00582                   }
00583               };
00584             if(count > 0)
00585               rsbac_vfree(set_array);
00586             break;
00587           }
00588 
00589         case PA_ru_set:
00590           {
00591             rsbac_pm_ru_set_id_t * set_array;
00592             rsbac_uid_t          * member_array;
00593 
00594             count = rsbac_list_lol_get_all_desc(ru_set_handle, (void **) &set_array);
00595             if(count < 0)
00596               {
00597                 return count;
00598               }
00599             len += sprintf(buffer + len, "ru-set\t\tmembers\n");
00600             for(i=0; i<count; i++)
00601               {
00602                 len += sprintf(buffer + len, "%u\t\t",
00603                                set_array[i]);
00604                 pos = begin + len;
00605                 if (pos < offset)
00606                   {
00607                     len = 0;
00608                     begin = pos;
00609                   }
00610                 if (pos > offset+length)
00611                   {
00612                     rsbac_vfree(set_array);
00613                     goto out;
00614                   }
00615 
00616                 subcount = rsbac_list_lol_get_all_subdesc(ru_set_handle,
00617                                                           &set_array[i],
00618                                                           (void **) &member_array);
00619                 if(subcount < 0)
00620                   {
00621                     rsbac_vfree(set_array);
00622                     goto out;
00623                   }
00624                 for(j=0; j<subcount; j++)
00625                   {
00626                     len += sprintf(buffer + len, "%u ",
00627                                    member_array[j]);
00628                     pos = begin + len;
00629                     if (pos < offset)
00630                       {
00631                         len = 0;
00632                         begin = pos;
00633                       }
00634                     if (pos > offset+length)
00635                       {
00636                         rsbac_vfree(set_array);
00637                         rsbac_vfree(member_array);
00638                         goto out;
00639                       }
00640                   };
00641                 if(subcount > 0)
00642                   rsbac_vfree(member_array);
00643                 len += sprintf(buffer + len, "\n");
00644                 pos = begin + len;
00645                 if (pos < offset)
00646                   {
00647                     len = 0;
00648                     begin = pos;
00649                   }
00650                 if (pos > offset+length)
00651                   {
00652                     rsbac_vfree(set_array);
00653                     goto out;
00654                   }
00655               };
00656             if(count > 0)
00657               rsbac_vfree(set_array);
00658             break;
00659           }
00660 
00661         case PA_pp_set:
00662           {
00663             rsbac_pm_pp_set_id_t  * set_array;
00664             rsbac_pm_purpose_id_t * member_array;
00665 
00666             count = rsbac_list_lol_get_all_desc(pp_set_handle, (void **) &set_array);
00667             if(count < 0)
00668               {
00669                 return count;
00670               }
00671             len += sprintf(buffer + len, "pp-set\t\tmembers\n");
00672             for(i=0; i<count; i++)
00673               {
00674                 len += sprintf(buffer + len, "%u\t\t",
00675                                set_array[i]);
00676                 pos = begin + len;
00677                 if (pos < offset)
00678                   {
00679                     len = 0;
00680                     begin = pos;
00681                   }
00682                 if (pos > offset+length)
00683                   {
00684                     rsbac_vfree(set_array);
00685                     goto out;
00686                   }
00687 
00688                 subcount = rsbac_list_lol_get_all_subdesc(pp_set_handle,
00689                                                           &set_array[i],
00690                                                           (void **) &member_array);
00691                 if(subcount < 0)
00692                   {
00693                     rsbac_vfree(set_array);
00694                     goto out;
00695                   }
00696                 for(j=0; j<subcount; j++)
00697                   {
00698                     len += sprintf(buffer + len, "%u ",
00699                                    member_array[j]);
00700                     pos = begin + len;
00701                     if (pos < offset)
00702                       {
00703                         len = 0;
00704                         begin = pos;
00705                       }
00706                     if (pos > offset+length)
00707                       {
00708                         rsbac_vfree(set_array);
00709                         rsbac_vfree(member_array);
00710                         goto out;
00711                       }
00712                   };
00713                 if(subcount > 0)
00714                   rsbac_vfree(member_array);
00715                 len += sprintf(buffer + len, "\n");
00716                 pos = begin + len;
00717                 if (pos < offset)
00718                   {
00719                     len = 0;
00720                     begin = pos;
00721                   }
00722                 if (pos > offset+length)
00723                   {
00724                     rsbac_vfree(set_array);
00725                     goto out;
00726                   }
00727               };
00728             if(count > 0)
00729               rsbac_vfree(set_array);
00730             break;
00731           }
00732 
00733         case PA_in_pp_set:
00734           {
00735             rsbac_pm_in_pp_set_id_t * set_array;
00736             rsbac_pm_purpose_id_t   * member_array;
00737 
00738             count = rsbac_list_lol_get_all_desc(in_pp_set_handle, (void **) &set_array);
00739             if(count < 0)
00740               {
00741                 return count;
00742               }
00743 
00744             len += sprintf(buffer + len, "in-pp-set\tmembers\n");
00745             for(i=0; i<count; i++)
00746               {
00747                 len += sprintf(buffer + len, "%u\t\t",
00748                                set_array[i]);
00749                 pos = begin + len;
00750                 if (pos < offset)
00751                   {
00752                     len = 0;
00753                     begin = pos;
00754                   }
00755                 if (pos > offset+length)
00756                   {
00757                     rsbac_vfree(set_array);
00758                     goto out;
00759                   }
00760 
00761                 subcount = rsbac_list_lol_get_all_subdesc(in_pp_set_handle,
00762                                                           &set_array[i],
00763                                                           (void **) &member_array);
00764                 if(subcount < 0)
00765                   {
00766                     rsbac_vfree(set_array);
00767                     goto out;
00768                   }
00769                 for(j=0; j<subcount; j++)
00770                   {
00771                     len += sprintf(buffer + len, "%u ",
00772                                    member_array[j]);
00773                     pos = begin + len;
00774                     if (pos < offset)
00775                       {
00776                         len = 0;
00777                         begin = pos;
00778                       }
00779                     if (pos > offset+length)
00780                       {
00781                         rsbac_vfree(set_array);
00782                         rsbac_vfree(member_array);
00783                         goto out;
00784                       }
00785                   };
00786                 if(subcount > 0)
00787                   rsbac_vfree(member_array);
00788                 len += sprintf(buffer + len, "\n");
00789                 pos = begin + len;
00790                 if (pos < offset)
00791                   {
00792                     len = 0;
00793                     begin = pos;
00794                   }
00795                 if (pos > offset+length)
00796                   {
00797                     rsbac_vfree(set_array);
00798                     goto out;
00799                   }
00800               };
00801             if(count > 0)
00802               rsbac_vfree(set_array);
00803             break;
00804           }
00805 
00806         case PA_out_pp_set:
00807           {
00808             rsbac_pm_out_pp_set_id_t * set_array;
00809             rsbac_pm_purpose_id_t    * member_array;
00810 
00811             count = rsbac_list_lol_get_all_desc(out_pp_set_handle, (void **) &set_array);
00812             if(count < 0)
00813               {
00814                 return count;
00815               }
00816 
00817             len += sprintf(buffer + len, "out-pp-set\tmembers\n");
00818             for(i=0; i<count; i++)
00819               {
00820                 len += sprintf(buffer + len, "%u\t\t",
00821                                set_array[i]);
00822                 pos = begin + len;
00823                 if (pos < offset)
00824                   {
00825                     len = 0;
00826                     begin = pos;
00827                   }
00828                 if (pos > offset+length)
00829                   {
00830                     rsbac_vfree(set_array);
00831                     goto out;
00832                   }
00833 
00834                 subcount = rsbac_list_lol_get_all_subdesc(out_pp_set_handle,
00835                                                           &set_array[i],
00836                                                           (void **) &member_array);
00837                 if(subcount < 0)
00838                   {
00839                     rsbac_vfree(set_array);
00840                     goto out;
00841                   }
00842                 for(j=0; j<subcount; j++)
00843                   {
00844                     len += sprintf(buffer + len, "%u ",
00845                                    member_array[j]);
00846                     pos = begin + len;
00847                     if (pos < offset)
00848                       {
00849                         len = 0;
00850                         begin = pos;
00851                       }
00852                     if (pos > offset+length)
00853                       {
00854                         rsbac_vfree(set_array);
00855                         rsbac_vfree(member_array);
00856                         goto out;
00857                       }
00858                   };
00859                 if(subcount > 0)
00860                   rsbac_vfree(member_array);
00861                 len += sprintf(buffer + len, "\n");
00862                 pos = begin + len;
00863                 if (pos < offset)
00864                   {
00865                     len = 0;
00866                     begin = pos;
00867                   }
00868                 if (pos > offset+length)
00869                   {
00870                     rsbac_vfree(set_array);
00871                     goto out;
00872                   }
00873               };
00874             if(count > 0)
00875               rsbac_vfree(set_array);
00876             break;
00877           }
00878 
00879 /***********/
00880           
00881         case PA_task:
00882           {
00883             rsbac_pm_task_id_t * desc_array;
00884 
00885             count = rsbac_list_get_all_desc(task_handle, (void **) &desc_array);
00886             if(count < 0)
00887               {
00888                 return count;
00889               }
00890 
00891             len += sprintf(buffer + len, "task-id\n");
00892             for(i=0; i<count; i++)
00893               {
00894                 len += sprintf(buffer + len, "%u\n",
00895                                desc_array[i]);
00896                 pos = begin + len;
00897                 if (pos < offset)
00898                   {
00899                     len = 0;
00900                     begin = pos;
00901                   }
00902                 if (pos > offset+length)
00903                   {
00904                     rsbac_vfree(desc_array);
00905                     goto out;
00906                   }
00907               };
00908             if(count > 0)
00909               rsbac_vfree(desc_array);
00910             break;
00911           }
00912 
00913         case PA_class:
00914           {
00915             rsbac_pm_object_class_id_t * desc_array;
00916 
00917             count = rsbac_list_get_all_desc(class_handle, (void **) &desc_array);
00918             if(count < 0)
00919               {
00920                 return count;
00921               }
00922 
00923             len += sprintf(buffer + len, "class-id\n");
00924             for(i=0; i<count; i++)
00925               {
00926                 len += sprintf(buffer + len, "%u\n",
00927                                desc_array[i]);
00928                 pos = begin + len;
00929                 if (pos < offset)
00930                   {
00931                     len = 0;
00932                     begin = pos;
00933                   }
00934                 if (pos > offset+length)
00935                   {
00936                     rsbac_vfree(desc_array);
00937                     goto out;
00938                   }
00939               };
00940             if(count > 0)
00941               rsbac_vfree(desc_array);
00942             break;
00943           }
00944 
00945         case PA_na:
00946           {
00947             struct rsbac_pm_na_data_t * data_array;
00948 
00949             count = rsbac_list_get_all_data(na_handle, (void **) &data_array);
00950             if(count < 0)
00951               {
00952                 return count;
00953               }
00954             len += sprintf(buffer + len, "task\tclass\ttp\taccesses\n");
00955             for(i=0; i<count; i++)
00956               {
00957                 len += sprintf(buffer + len, "%u\t%u\t%u\t%u\n",
00958                                data_array[i].task,
00959                                data_array[i].object_class,
00960                                data_array[i].tp,
00961                                data_array[i].accesses);
00962                 pos = begin + len;
00963                 if (pos < offset)
00964                   {
00965                     len = 0;
00966                     begin = pos;
00967                   }
00968                 if (pos > offset+length)
00969                   {
00970                     rsbac_vfree(data_array);
00971                     goto out;
00972                   }
00973               };
00974             if(count > 0)
00975               rsbac_vfree(data_array);
00976             break;
00977           }
00978           
00979         case PA_cs:
00980           {
00981             struct rsbac_pm_cs_id_t * desc_array;
00982 
00983             count = rsbac_list_get_all_desc(cs_handle, (void **) &desc_array);
00984             if(count < 0)
00985               {
00986                 return count;
00987               }
00988             len += sprintf(buffer + len, "purpose\tdevice\tinode\n");
00989             for(i=0; i<count; i++)
00990               {
00991                 len += sprintf(buffer + len, "%u\t%02u:02%u\t%u\n",
00992                                desc_array[i].purpose,
00993                                RSBAC_MAJOR(desc_array[i].file.device),
00994                                RSBAC_MINOR(desc_array[i].file.device),
00995                                desc_array[i].file.inode);
00996                 pos = begin + len;
00997                 if (pos < offset)
00998                   {
00999                     len = 0;
01000                     begin = pos;
01001                   }
01002                 if (pos > offset+length)
01003                   {
01004                     rsbac_vfree(desc_array);
01005                     goto out;
01006                   }
01007               };
01008             if(count > 0)
01009               rsbac_vfree(desc_array);
01010             break;
01011           }
01012           
01013         case PA_tp:
01014           {
01015             rsbac_pm_tp_id_t * desc_array;
01016 
01017             count = rsbac_list_get_all_desc(tp_handle, (void **) &desc_array);
01018             if(count < 0)
01019               {
01020                 return count;
01021               }
01022 
01023             len += sprintf(buffer + len, "tp-id\n");
01024             for(i=0; i<count; i++)
01025               {
01026                 len += sprintf(buffer + len, "%u\n",
01027                                desc_array[i]);
01028                 pos = begin + len;
01029                 if (pos < offset)
01030                   {
01031                     len = 0;
01032                     begin = pos;
01033                   }
01034                 if (pos > offset+length)
01035                   {
01036                     rsbac_vfree(desc_array);
01037                     goto out;
01038                   }
01039               };
01040             if(count > 0)
01041               rsbac_vfree(desc_array);
01042             break;
01043           }
01044           
01045         case PA_pp:
01046           {
01047             struct rsbac_pm_pp_data_t * data_array;
01048 
01049             count = rsbac_list_get_all_data(pp_handle, (void **) &data_array);
01050             if(count < 0)
01051               {
01052                 return count;
01053               }
01054             len += sprintf(buffer + len, "purpose\tdef-class\n");
01055             for(i=0; i<count; i++)
01056               {
01057                 len += sprintf(buffer + len, "%u\t%u\n",
01058                                data_array[i].id,
01059                                data_array[i].def_class);
01060                 pos = begin + len;
01061                 if (pos < offset)
01062                   {
01063                     len = 0;
01064                     begin = pos;
01065                   }
01066                 if (pos > offset+length)
01067                   {
01068                     rsbac_vfree(data_array);
01069                     goto out;
01070                   }
01071               };
01072             if(count > 0)
01073               rsbac_vfree(data_array);
01074             break;
01075           }
01076 
01077         case PA_tkt:
01078           {
01079             struct rsbac_pm_tkt_data_t * data_array;
01080 
01081             count = rsbac_list_get_all_data(tkt_handle, (void **) &data_array);
01082             if(count < 0)
01083               {
01084                 return count;
01085               }
01086             len += sprintf(buffer + len, "tkt-id\tvalid-for\tfunction-type\n");
01087             for(i=0; i<count; i++)
01088               {
01089                 char tmp1[RSBAC_MAXNAMELEN];
01090                 char tmp2[RSBAC_MAXNAMELEN];
01091 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
01092                 struct timespec now = CURRENT_TIME;
01093 #endif
01094 
01095                 tmp2[0] = 0;
01096 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
01097                 if(data_array[i].valid_until < now.tv_sec)
01098 #else
01099                 if(data_array[i].valid_until < CURRENT_TIME)
01100 #endif
01101                   {
01102                     strcpy(tmp2,"\t(removed on cleanup)");
01103                   }
01104                 len += sprintf(buffer + len, "%u\t%li\t\t%s%s\n",
01105                                data_array[i].id,
01106 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
01107                                data_array[i].valid_until - now.tv_sec,
01108 #else
01109                                data_array[i].valid_until - CURRENT_TIME,
01110 #endif
01111                                get_pm_function_type_name(tmp1, data_array[i].function_type),
01112                                tmp2);
01113                 pos = begin + len;
01114                 if (pos < offset)
01115                   {
01116                     len = 0;
01117                     begin = pos;
01118                   }
01119                 if (pos > offset+length)
01120                   {
01121                     rsbac_vfree(data_array);
01122                     goto out;
01123                   }
01124               };
01125             if(count > 0)
01126               rsbac_vfree(data_array);
01127             break;
01128           }
01129           
01130         default:
01131 #ifdef CONFIG_RSBAC_RMSG
01132           rsbac_printk(KERN_WARNING
01133                  "pm_list_proc_read(): access to unknown list %i\n", list);
01134 #endif
01135 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
01136           if (!rsbac_nosyslog)
01137 #endif
01138           printk(KERN_WARNING
01139                  "pm_list_proc_read(): access to unknown list %i\n", list);
01140           return(-RSBAC_EINVALIDTARGET);
01141       }
01142 
01143   out:
01144     if(len <= offset+length)
01145       *eof=1;
01146     *start = buffer + (offset - begin);
01147     len -= (offset - begin);
01148   
01149     if (len > length)
01150       len = length;
01151     return len;
01152   }; /* end of list_proc_read */
01153 
01154 #endif /* CONFIG_PROC_FS && CONFIG_RSBAC_PROC */
01155 
01156 /************************************************* */
01157 /*               Init functions                    */
01158 /************************************************* */
01159 
01160 #ifdef CONFIG_RSBAC_INIT_DELAY
01161 static void registration_error(int err, char * listname)
01162 #else
01163 static void __init registration_error(int err, char * listname)
01164 #endif
01165   {
01166     if(err)
01167       {
01168         char * tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
01169 
01170         if(tmp)
01171           {
01172 #ifdef CONFIG_RSBAC_RMSG
01173             rsbac_printk(KERN_WARNING
01174                    "rsbac_init_pm(): Registering PM %s list failed with error %s\n",
01175                    listname,
01176                    get_error_name(tmp, err));
01177 #endif
01178 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
01179             if (!rsbac_nosyslog)
01180 #endif
01181             printk(KERN_WARNING
01182                    "rsbac_init_pm(): Registering PM %s list failed with error %s\n",
01183                    listname,
01184                    get_error_name(tmp, err));
01185             rsbac_kfree(tmp);
01186           }
01187       }
01188   }
01189 
01190 /* All functions return 0, if no error occurred, and a negative error code  */
01191 /* otherwise. The error codes are defined in rsbac/error.h.                 */
01192 
01193 /************************************************************************** */
01194 /* Initialization of all PM data structures. After this call, all PM data   */
01195 /* is kept in memory for performance reasons, but is written to disk on     */
01196 /* every change.    */
01197 
01198 #ifdef CONFIG_RSBAC_INIT_DELAY
01199 int rsbac_init_pm(void)
01200 #else
01201 int __init rsbac_init_pm(void)
01202 #endif
01203   {
01204     int  err = 0;
01205     struct proc_dir_entry * tmp_entry_p;
01206     struct proc_dir_entry * pm_entry_p;
01207     struct rsbac_list_lol_info_t lol_info;
01208     struct rsbac_list_info_t     list_info;
01209 
01210     if (rsbac_is_initialized())
01211       {
01212         printk(KERN_WARNING "rsbac_init_pm(): RSBAC already initialized\n");
01213         return(-RSBAC_EREINIT);
01214       }
01215 
01216 #ifdef CONFIG_RSBAC_RMSG
01217     rsbac_printk(KERN_INFO "rsbac_init_pm(): Initializing RSBAC: PM subsystem\n");
01218 #endif
01219 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
01220     if (!rsbac_nosyslog)
01221 #endif
01222     printk(KERN_INFO "rsbac_init_pm(): Initializing RSBAC: PM subsystem\n");
01223 
01224 /* Helper lists */
01225     lol_info.version = RSBAC_PM_TASK_SET_LIST_VERSION;
01226     lol_info.key = RSBAC_PM_LIST_KEY;
01227     lol_info.desc_size = sizeof(rsbac_pm_task_set_id_t);
01228     lol_info.data_size = 0;
01229     lol_info.subdesc_size = sizeof(rsbac_pm_task_id_t);
01230     lol_info.subdata_size = 0;
01231     lol_info.max_age = 0;
01232     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01233                                   &task_set_handle,
01234                                   &lol_info,
01235                                   RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01236                                   rsbac_list_compare_u32,
01237                                   rsbac_list_compare_u32,
01238                                   NULL,
01239                                   NULL,
01240                                   NULL,
01241                                   NULL,
01242                                   RSBAC_PM_TASK_SET_LIST_NAME,
01243                                   RSBAC_AUTO_DEV);
01244     if(err)
01245       {
01246         registration_error(err, "task set");
01247         return err;
01248       }
01249 
01250     lol_info.version = RSBAC_PM_TP_SET_LIST_VERSION;
01251     lol_info.key = RSBAC_PM_LIST_KEY;
01252     lol_info.desc_size = sizeof(rsbac_pm_tp_set_id_t);
01253     lol_info.data_size = 0;
01254     lol_info.subdesc_size = sizeof(rsbac_pm_tp_id_t);
01255     lol_info.subdata_size = 0;
01256     lol_info.max_age = 0;
01257     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01258                                   &tp_set_handle,
01259                                   &lol_info,
01260                                   RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01261                                   rsbac_list_compare_u32,
01262                                   rsbac_list_compare_u32,
01263                                   NULL,
01264                                   NULL,
01265                                   NULL,
01266                                   NULL,
01267                                   RSBAC_PM_TP_SET_LIST_NAME,
01268                                   RSBAC_AUTO_DEV);
01269     if(err)
01270       {
01271         registration_error(err, "tp set");
01272         return err;
01273       }
01274 
01275     lol_info.version = RSBAC_PM_RU_SET_LIST_VERSION;
01276     lol_info.key = RSBAC_PM_LIST_KEY;
01277     lol_info.desc_size = sizeof(rsbac_pm_ru_set_id_t);
01278     lol_info.data_size = 0;
01279     lol_info.subdesc_size = sizeof(rsbac_uid_t);
01280     lol_info.subdata_size = 0;
01281     lol_info.max_age = 0;
01282     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01283                                   &ru_set_handle,
01284                                   &lol_info,
01285                                   RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01286                                   rsbac_list_compare_u32,
01287                                   rsbac_list_compare_u32,
01288                                   NULL,
01289                                   NULL,
01290                                   NULL,
01291                                   NULL,
01292                                   RSBAC_PM_RU_SET_LIST_NAME,
01293                                   RSBAC_AUTO_DEV);
01294     if(err)
01295       {
01296         registration_error(err, "ru set");
01297         return err;
01298       }
01299 
01300     lol_info.version = RSBAC_PM_PP_SET_LIST_VERSION;
01301     lol_info.key = RSBAC_PM_LIST_KEY;
01302     lol_info.desc_size = sizeof(rsbac_pm_pp_set_id_t);
01303     lol_info.data_size = 0;
01304     lol_info.subdesc_size = sizeof(rsbac_pm_purpose_id_t);
01305     lol_info.subdata_size = 0;
01306     lol_info.max_age = 0;
01307     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01308                                   &pp_set_handle,
01309                                   &lol_info,
01310                                   RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01311                                   rsbac_list_compare_u32,
01312                                   rsbac_list_compare_u32,
01313                                   NULL,
01314                                   NULL,
01315                                   NULL,
01316                                   NULL,
01317                                   RSBAC_PM_PP_SET_LIST_NAME,
01318                                   RSBAC_AUTO_DEV);
01319     if(err)
01320       {
01321         registration_error(err, "pp set");
01322         return err;
01323       }
01324 
01325     lol_info.version = RSBAC_PM_NO_VERSION;
01326     lol_info.key = RSBAC_PM_LIST_KEY;
01327     lol_info.desc_size = sizeof(rsbac_pm_in_pp_set_id_t);
01328     lol_info.data_size = 0;
01329     lol_info.subdesc_size = sizeof(rsbac_pm_purpose_id_t);
01330     lol_info.subdata_size = 0;
01331     lol_info.max_age = 0;
01332     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01333                                   &in_pp_set_handle,
01334                                   &lol_info,
01335                                   0,
01336                                   rsbac_list_compare_u32,
01337                                   rsbac_list_compare_u32,
01338                                   NULL,
01339                                   NULL,
01340                                   NULL,
01341                                   NULL,
01342                                   RSBAC_PM_IN_PP_SET_LIST_NAME,
01343                                   RSBAC_AUTO_DEV);
01344     if(err)
01345       {
01346         registration_error(err, "in_pp set");
01347         return err;
01348       }
01349 
01350     lol_info.version = RSBAC_PM_NO_VERSION;
01351     lol_info.key = RSBAC_PM_LIST_KEY;
01352     lol_info.desc_size = sizeof(rsbac_pm_out_pp_set_id_t);
01353     lol_info.data_size = 0;
01354     lol_info.subdesc_size = sizeof(rsbac_pm_purpose_id_t);
01355     lol_info.subdata_size = 0;
01356     lol_info.max_age = 0;
01357     err = rsbac_list_lol_register(RSBAC_LIST_VERSION,
01358                                   &out_pp_set_handle,
01359                                   &lol_info,
01360                                   0,
01361                                   rsbac_list_compare_u32,
01362                                   rsbac_list_compare_u32,
01363                                   NULL,
01364                                   NULL,
01365                                   NULL,
01366                                   NULL,
01367                                   RSBAC_PM_OUT_PP_SET_LIST_NAME,
01368                                   RSBAC_AUTO_DEV);
01369     if(err)
01370       {
01371         registration_error(err, "out_pp set");
01372         return err;
01373       }
01374 
01375 /* Main lists */
01376     list_info.version = RSBAC_PM_TASK_LIST_VERSION;
01377     list_info.key = RSBAC_PM_LIST_KEY;
01378     list_info.desc_size = sizeof(rsbac_pm_task_id_t);
01379     list_info.data_size = sizeof(struct rsbac_pm_task_data_t);
01380     list_info.max_age = 0;
01381     err = rsbac_list_register(RSBAC_LIST_VERSION,
01382                               &task_handle,
01383                               &list_info,
01384                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01385                               rsbac_list_compare_u32,
01386                               NULL,
01387                               NULL,
01388                               RSBAC_PM_TASK_LIST_NAME,
01389                               RSBAC_AUTO_DEV);
01390     if(err)
01391       {
01392         registration_error(err, "task");
01393         return err;
01394       }
01395 
01396     list_info.version = RSBAC_PM_CLASS_LIST_VERSION;
01397     list_info.key = RSBAC_PM_LIST_KEY;
01398     list_info.desc_size = sizeof(rsbac_pm_object_class_id_t);
01399     list_info.data_size = sizeof(struct rsbac_pm_class_data_t);
01400     list_info.max_age = 0;
01401     err = rsbac_list_register(RSBAC_LIST_VERSION,
01402                               &class_handle,
01403                               &list_info,
01404                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01405                               rsbac_list_compare_u32,
01406                               NULL,
01407                               NULL,
01408                               RSBAC_PM_CLASS_LIST_NAME,
01409                               RSBAC_AUTO_DEV);
01410     if(err)
01411       {
01412         registration_error(err, "class");
01413         return err;
01414       }
01415 
01416     list_info.version = RSBAC_PM_NA_LIST_VERSION;
01417     list_info.key = RSBAC_PM_LIST_KEY;
01418     list_info.desc_size = sizeof(struct rsbac_pm_na_id_t);
01419     list_info.data_size = sizeof(struct rsbac_pm_na_data_t);
01420     list_info.max_age = 0;
01421     err = rsbac_list_register(RSBAC_LIST_VERSION,
01422                               &na_handle,
01423                               &list_info,
01424                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01425                               rsbac_list_compare_u32,
01426                               NULL,
01427                               NULL,
01428                               RSBAC_PM_NA_LIST_NAME,
01429                               RSBAC_AUTO_DEV);
01430     if(err)
01431       {
01432         registration_error(err, "na");
01433         return err;
01434       }
01435 
01436     list_info.version = RSBAC_PM_CS_LIST_VERSION;
01437     list_info.key = RSBAC_PM_LIST_KEY;
01438     list_info.desc_size = sizeof(struct rsbac_pm_cs_id_t);
01439     list_info.data_size = sizeof(struct rsbac_pm_cs_data_t);
01440     list_info.max_age = 0;
01441     err = rsbac_list_register(RSBAC_LIST_VERSION,
01442                               &cs_handle,
01443                               &list_info,
01444                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01445                               rsbac_list_compare_u32,
01446                               NULL,
01447                               NULL,
01448                               RSBAC_PM_CS_LIST_NAME,
01449                               RSBAC_AUTO_DEV);
01450     if(err)
01451       {
01452         registration_error(err, "cs");
01453         return err;
01454       }
01455 
01456     list_info.version = RSBAC_PM_TP_LIST_VERSION;
01457     list_info.key = RSBAC_PM_LIST_KEY;
01458     list_info.desc_size = sizeof(rsbac_pm_tp_id_t);
01459     list_info.data_size = sizeof(struct rsbac_pm_tp_data_t);
01460     list_info.max_age = 0;
01461     err = rsbac_list_register(RSBAC_LIST_VERSION,
01462                               &tp_handle,
01463                               &list_info,
01464                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01465                               rsbac_list_compare_u32,
01466                               NULL,
01467                               NULL,
01468                               RSBAC_PM_TP_LIST_NAME,
01469                               RSBAC_AUTO_DEV);
01470     if(err)
01471       {
01472         registration_error(err, "tp");
01473         return err;
01474       }
01475 
01476     list_info.version = RSBAC_PM_PP_LIST_VERSION;
01477     list_info.key = RSBAC_PM_LIST_KEY;
01478     list_info.desc_size = sizeof(rsbac_pm_purpose_id_t);
01479     list_info.data_size = sizeof(struct rsbac_pm_pp_data_t);
01480     list_info.max_age = 0;
01481     err = rsbac_list_register(RSBAC_LIST_VERSION,
01482                               &pp_handle,
01483                               &list_info,
01484                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01485                               rsbac_list_compare_u32,
01486                               NULL,
01487                               NULL,
01488                               RSBAC_PM_PP_LIST_NAME,
01489                               RSBAC_AUTO_DEV);
01490     if(err)
01491       {
01492         registration_error(err, "pp");
01493         return err;
01494       }
01495 
01496     list_info.version = RSBAC_PM_TKT_LIST_VERSION;
01497     list_info.key = RSBAC_PM_LIST_KEY;
01498     list_info.desc_size = sizeof(rsbac_pm_tkt_id_t);
01499     list_info.data_size = sizeof(struct rsbac_pm_tkt_data_t);
01500     list_info.max_age = 0;
01501     err = rsbac_list_register(RSBAC_LIST_VERSION,
01502                               &tkt_handle,
01503                               &list_info,
01504                               RSBAC_LIST_PERSIST | RSBAC_LIST_BACKUP,
01505                               rsbac_list_compare_u32,
01506                               NULL,
01507                               NULL,
01508                               RSBAC_PM_TKT_LIST_NAME,
01509                               RSBAC_AUTO_DEV);
01510     if(err)
01511       {
01512         registration_error(err, "tkt");
01513         return err;
01514       }
01515 
01516     #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS)
01517     tmp_entry_p = create_proc_entry(RSBAC_PM_PROC_STATS_NAME,
01518                                     S_IFREG | S_IRUGO,
01519                                     proc_rsbac_root_p);
01520     if(tmp_entry_p)
01521       {
01522         tmp_entry_p->get_info = stats_pm_proc_info;
01523       }
01524 
01525     pm_entry_p = create_proc_entry(RSBAC_PM_PROC_DIR_NAME,
01526                                    S_IFDIR | S_IRUGO | S_IXUGO,
01527                                    proc_rsbac_root_p);
01528     if(pm_entry_p)
01529       {
01530         tmp_entry_p = create_proc_entry(RSBAC_PM_TASK_SET_LIST_PROC_NAME,
01531                                         S_IFREG | S_IRUGO,
01532                                         pm_entry_p);
01533         if(tmp_entry_p)
01534           {
01535             tmp_entry_p->read_proc = pm_list_proc_read;
01536             tmp_entry_p->data = (void *) PA_task_set;
01537           }
01538         tmp_entry_p = create_proc_entry(RSBAC_PM_TP_SET_LIST_PROC_NAME,
01539                                         S_IFREG | S_IRUGO,
01540                                         pm_entry_p);
01541         if(tmp_entry_p)
01542           {
01543             tmp_entry_p->read_proc = pm_list_proc_read;
01544             tmp_entry_p->data = (void *) PA_tp_set;
01545           }
01546         tmp_entry_p = create_proc_entry(RSBAC_PM_RU_SET_LIST_PROC_NAME,
01547                                         S_IFREG | S_IRUGO,
01548                                         pm_entry_p);
01549         if(tmp_entry_p)
01550           {
01551             tmp_entry_p->read_proc = pm_list_proc_read;
01552             tmp_entry_p->data = (void *) PA_ru_set;
01553           }
01554         tmp_entry_p = create_proc_entry(RSBAC_PM_PP_SET_LIST_PROC_NAME,
01555                                         S_IFREG | S_IRUGO,
01556                                         pm_entry_p);
01557         if(tmp_entry_p)
01558           {
01559             tmp_entry_p->read_proc = pm_list_proc_read;
01560             tmp_entry_p->data = (void *) PA_pp_set;
01561           }
01562         tmp_entry_p = create_proc_entry(RSBAC_PM_IN_PP_SET_LIST_PROC_NAME,
01563                                         S_IFREG | S_IRUGO,
01564                                         pm_entry_p);
01565         if(tmp_entry_p)
01566           {
01567             tmp_entry_p->read_proc = pm_list_proc_read;
01568             tmp_entry_p->data = (void *) PA_in_pp_set;
01569           }
01570         tmp_entry_p = create_proc_entry(RSBAC_PM_OUT_PP_SET_LIST_PROC_NAME,
01571                                         S_IFREG | S_IRUGO,
01572                                         pm_entry_p);
01573         if(tmp_entry_p)
01574           {
01575             tmp_entry_p->read_proc = pm_list_proc_read;
01576             tmp_entry_p->data = (void *) PA_out_pp_set;
01577           }
01578 
01579         tmp_entry_p = create_proc_entry(RSBAC_PM_TASK_LIST_PROC_NAME,
01580                                         S_IFREG | S_IRUGO,
01581                                         pm_entry_p);
01582         if(tmp_entry_p)
01583           {
01584             tmp_entry_p->read_proc = pm_list_proc_read;
01585             tmp_entry_p->data = (void *) PA_task;
01586           }
01587         tmp_entry_p = create_proc_entry(RSBAC_PM_CLASS_LIST_PROC_NAME,
01588                                         S_IFREG | S_IRUGO,
01589                                         pm_entry_p);
01590         if(tmp_entry_p)
01591           {
01592             tmp_entry_p->read_proc = pm_list_proc_read;
01593             tmp_entry_p->data = (void *) PA_class;
01594           }
01595         tmp_entry_p = create_proc_entry(RSBAC_PM_NA_LIST_PROC_NAME,
01596                                         S_IFREG | S_IRUGO,
01597                                         pm_entry_p);
01598         if(tmp_entry_p)
01599           {
01600             tmp_entry_p->read_proc = pm_list_proc_read;
01601             tmp_entry_p->data = (void *) PA_na;
01602           }
01603         tmp_entry_p = create_proc_entry(RSBAC_PM_CS_LIST_PROC_NAME,
01604                                         S_IFREG | S_IRUGO,
01605                                         pm_entry_p);
01606         if(tmp_entry_p)
01607           {
01608             tmp_entry_p->read_proc = pm_list_proc_read;
01609             tmp_entry_p->data = (void *) PA_cs;
01610           }
01611         tmp_entry_p = create_proc_entry(RSBAC_PM_TP_LIST_PROC_NAME,
01612                                         S_IFREG | S_IRUGO,
01613                                         pm_entry_p);
01614         if(tmp_entry_p)
01615           {
01616             tmp_entry_p->read_proc = pm_list_proc_read;
01617             tmp_entry_p->data = (void *) PA_tp;
01618           }
01619         tmp_entry_p = create_proc_entry(RSBAC_PM_PP_LIST_PROC_NAME,
01620                                         S_IFREG | S_IRUGO,
01621                                         pm_entry_p);
01622         if(tmp_entry_p)
01623           {
01624             tmp_entry_p->read_proc = pm_list_proc_read;
01625             tmp_entry_p->data = (void *) PA_pp;
01626           }
01627         tmp_entry_p = create_proc_entry(RSBAC_PM_TKT_LIST_PROC_NAME,
01628                                         S_IFREG | S_IRUGO,
01629                                         pm_entry_p);
01630         if(tmp_entry_p)
01631           {
01632             tmp_entry_p->read_proc = pm_list_proc_read;
01633             tmp_entry_p->data = (void *) PA_tkt;
01634           }
01635       }
01636     #endif
01637 
01638 #ifdef CONFIG_RSBAC_DEBUG
01639     if (rsbac_debug_ds_pm)
01640       {
01641 #ifdef CONFIG_RSBAC_RMSG
01642         rsbac_printk(KERN_DEBUG "rsbac_init_pm(): Ready.\n");
01643 #endif
01644 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
01645         if (!rsbac_nosyslog)
01646 #endif
01647         printk(KERN_DEBUG "rsbac_init_pm(): Ready.\n");
01648       }
01649 #endif
01650     return(err);
01651   };
01652 
01653 /***************************************************/
01654 /* We also need some status information...         */
01655 
01656 int rsbac_stats_pm(void)
01657   {
01658     u_long                                   tmp_count;
01659     u_long                                   tmp_member_count;
01660     u_long                                   all_set_count = 0;
01661     u_long                                   all_member_count = 0;
01662     u_long                               all_count = 0;
01663   
01664     if (!rsbac_is_initialized())
01665       {
01666 #ifdef CONFIG_RSBAC_RMSG
01667         rsbac_printk(KERN_WARNING "rsbac_stats_pm(): RSBAC not initialized\n");
01668 #endif
01669 #ifdef CONFIG_RSBAC_RMSG_NOSYSLOG
01670         if (!rsbac_nosyslog)
01671 #endif
01672         printk(KERN_WARNING "rsbac_stats_pm(): RSBAC not initialized\n");
01673         return(-RSBAC_ENOTINITIALIZED);
01674       }
01675 
01676 /****************/
01677 /* Helper lists */
01678 /****************/
01679 
01680     tmp_count = rsbac_list_lol_count(task_set_handle);
01681     tmp_member_count = rsbac_list_lol_all_subcount(task_set_handle);
01682     printk(KERN_INFO "rsbac_stats_pm(): %lu task-set-items, sum of %lu members\n",
01683                  tmp_count, tmp_member_count);
01684     all_set_count += tmp_count;
01685     all_member_count += tmp_member_count;
01686 
01687     tmp_count = rsbac_list_lol_count(tp_set_handle);
01688     tmp_member_count = rsbac_list_lol_all_subcount(tp_set_handle);
01689     printk(KERN_INFO "rsbac_stats_pm(): %lu tp set items, sum of %lu members\n",
01690                  tmp_count, tmp_member_count);
01691     all_set_count += tmp_count;
01692     all_member_count += tmp_member_count;
01693 
01694     tmp_count = rsbac_list_lol_count(ru_set_handle);
01695     tmp_member_count = rsbac_list_lol_all_subcount(ru_set_handle);
01696     printk(KERN_INFO "rsbac_stats_pm(): %lu ru set items, sum of %lu members\n",
01697                  tmp_count, tmp_member_count);
01698     all_set_count += tmp_count;
01699     all_member_count += tmp_member_count;
01700 
01701     tmp_count = rsbac_list_lol_count(pp_set_handle);
01702     tmp_member_count = rsbac_list_lol_all_subcount(pp_set_handle);
01703     printk(KERN_INFO "rsbac_stats_pm(): %lu pp set items, sum of %lu members\n",
01704                  tmp_count, tmp_member_count);
01705     all_set_count += tmp_count;
01706     all_member_count += tmp_member_count;
01707 
01708     tmp_count = rsbac_list_lol_count(in_pp_set_handle);
01709     tmp_member_count = rsbac_list_lol_all_subcount(in_pp_set_handle);
01710     printk(KERN_INFO "rsbac_stats_pm(): %lu input purpose set items, sum of %lu members\n",
01711                  tmp_count, tmp_member_count);
01712     all_set_count += tmp_count;
01713     all_member_count += tmp_member_count;
01714 
01715     tmp_count = rsbac_list_lol_count(out_pp_set_handle);
01716     tmp_member_count = rsbac_list_lol_all_subcount(out_pp_set_handle);
01717     printk(KERN_INFO "rsbac_stats_pm(): %lu output purpose set items, sum of %lu members\n",
01718                  tmp_count, tmp_member_count);
01719     all_set_count += tmp_count;
01720     all_member_count += tmp_member_count;
01721 
01722     printk(KERN_INFO "rsbac_stats_pm(): Total of %lu registered rsbac-pm-set-items, %lu members\n",
01723                  all_set_count, all_member_count);
01724 
01725 /**************/
01726 /* Main lists */
01727 /**************/
01728     tmp_count = rsbac_list_lol_count(task_handle);
01729     printk(KERN_INFO "rsbac_stats_pm(): %lu task items\n",
01730                  tmp_count);
01731     all_count += tmp_count;
01732 
01733     tmp_count = rsbac_list_lol_count(class_handle);
01734     printk(KERN_INFO "rsbac_stats_pm(): %lu class items\n",
01735                  tmp_count);
01736     all_count += tmp_count;
01737 
01738     tmp_count = rsbac_list_lol_count(na_handle);
01739     printk(KERN_INFO "rsbac_stats_pm(): %lu na items\n",
01740                  tmp_count);
01741     all_count += tmp_count;
01742 
01743     tmp_count = rsbac_list_lol_count(cs_handle);
01744     printk(KERN_INFO "rsbac_stats_pm(): %lu cs items\n",
01745                  tmp_count);
01746     all_count += tmp_count;
01747 
01748     tmp_count = rsbac_list_lol_count(tp_handle);
01749     printk(KERN_INFO "rsbac_stats_pm(): %lu tp items\n",
01750                  tmp_count);
01751     all_count += tmp_count;
01752 
01753     tmp_count = rsbac_list_lol_count(pp_handle);
01754     printk(KERN_INFO "rsbac_stats_pm(): %lu pp items\n",
01755                  tmp_count);
01756     all_count += tmp_count;
01757 
01758     tmp_count = rsbac_list_lol_count(tkt_handle);
01759     printk(KERN_INFO "rsbac_stats_pm(): %lu tkt items\n",
01760                  tmp_count);
01761     all_count += tmp_count;
01762 
01763     printk(KERN_INFO "rsbac_stats_pm(): Total of %lu registered rsbac-pm-items\n",
01764                  all_count);
01765     return(0);
01766   };
01767 
01768 /************************************************* */
01769 /*               Access functions                  */
01770 /************************************************* */
01771 
01772 /***********************/
01773 /* Helper lists / sets */
01774 /***********************/
01775 
01776 /* Trying to access a never created or removed set returns an error!        */
01777 
01778 
01779 /* rsbac_pm_add_to_set */
01780 /* Add a set member to a set sublist. Set behaviour: also returns success, */
01781 /* if member was already in set! */
01782 
01783 int rsbac_pm_add_to_set(
01784         rsbac_list_ta_number_t ta_number,
01785   enum  rsbac_pm_set_t set,
01786   union rsbac_pm_set_id_t id,
01787   union rsbac_pm_set_member_t member)
01788   {
01789     switch(set)
01790       {
01791         case PS_TASK:
01792           return(rsbac_ta_list_lol_subadd_ttl(ta_number, task_set_handle, 0, &id.task_set, &member.task, NULL));
01793         case PS_TP:
01794           return(rsbac_ta_list_lol_subadd_ttl(ta_number, tp_set_handle, 0, &id.tp_set, &member.tp, NULL));
01795         case PS_RU:
01796           return(rsbac_ta_list_lol_subadd_ttl(ta_number, ru_set_handle, 0, &id.ru_set, &member.ru, NULL));
01797         case PS_PP:
01798           return(rsbac_ta_list_lol_subadd_ttl(ta_number, pp_set_handle, 0, &id.pp_set, &member.pp, NULL));
01799         case PS_IN_PP:
01800           return(rsbac_ta_list_lol_subadd_ttl(ta_number, in_pp_set_handle, 0, &id.in_pp_set, &member.pp, NULL));
01801         case PS_OUT_PP:
01802           return(rsbac_ta_list_lol_subadd_ttl(ta_number, out_pp_set_handle, 0, &id.out_pp_set, &member.pp, NULL));
01803         default:
01804           return(-RSBAC_EINVALIDTARGET);
01805       }
01806   }
01807 
01808 /* rsbac_pm_remove_from_set */
01809 /* Remove a set member from a sublist. Set behaviour: Returns no error, if */
01810 /* member is not in list.                                                  */
01811 /* Caution: Writing to disk is not done in the remove functions!               */
01812 
01813 int rsbac_pm_remove_from_set(
01814         rsbac_list_ta_number_t ta_number,
01815   enum  rsbac_pm_set_t set,
01816   union rsbac_pm_set_id_t id,
01817   union rsbac_pm_set_member_t member)
01818   {
01819     switch(set)
01820       {
01821         case PS_TASK:
01822           return(rsbac_ta_list_lol_subremove(ta_number, task_set_handle, &id.task_set, &member.task));
01823         case PS_TP:
01824           return(rsbac_ta_list_lol_subremove(ta_number, tp_set_handle, &id.tp_set, &member.tp));
01825         case PS_RU:
01826           return(rsbac_ta_list_lol_subremove(ta_number, ru_set_handle, &id.ru_set, &member.ru));
01827         case PS_PP:
01828           return(rsbac_ta_list_lol_subremove(ta_number, pp_set_handle, &id.pp_set, &member.pp));
01829         case PS_IN_PP:
01830           return(rsbac_ta_list_lol_subremove(ta_number, in_pp_set_handle, &id.in_pp_set, &member.pp));
01831         case PS_OUT_PP:
01832           return(rsbac_ta_list_lol_subremove(ta_number, out_pp_set_handle, &id.out_pp_set, &member.pp));
01833         default:
01834           return(-RSBAC_EINVALIDTARGET);
01835       }
01836   }
01837 
01838 /* rsbac_pm_clear_set */
01839 /* Remove all set members from a sublist. Set behaviour: Returns no error, */
01840 /* if list is empty.                                                       */
01841 /* Caution: Writing to disk is not done in the remove functions!               */
01842 
01843 int rsbac_pm_clear_set(
01844         rsbac_list_ta_number_t ta_number,
01845   enum  rsbac_pm_set_t set,
01846   union rsbac_pm_set_id_t id)
01847   {
01848     switch(set)
01849       {
01850         case PS_TASK:
01851           return(rsbac_ta_list_lol_subremove_all(ta_number, task_set_handle, &id.task_set));
01852         case PS_TP:
01853           return(rsbac_ta_list_lol_subremove_all(ta_number, tp_set_handle, &id.tp_set));
01854         case PS_RU:
01855           return(rsbac_ta_list_lol_subremove_all(ta_number, ru_set_handle, &id.ru_set));
01856         case PS_PP:
01857           return(rsbac_ta_list_lol_subremove_all(ta_number, pp_set_handle, &id.pp_set));
01858         case PS_IN_PP:
01859           return(rsbac_ta_list_lol_subremove_all(ta_number, in_pp_set_handle, &id.in_pp_set));
01860         case PS_OUT_PP:
01861           return(rsbac_ta_list_lol_subremove_all(ta_number, out_pp_set_handle, &id.out_pp_set));
01862         default:
01863           return(-RSBAC_EINVALIDTARGET);
01864       }
01865   }
01866 
01867 /* rsbac_pm_set_member */
01868 /* Return truth value, whether member is in set */
01869 
01870 rsbac_boolean_t  rsbac_pm_set_member(
01871         rsbac_list_ta_number_t ta_number,
01872   enum  rsbac_pm_set_t set,
01873   union rsbac_pm_set_id_t id,
01874   union rsbac_pm_set_member_t member)
01875   {
01876     switch(set)
01877       {
01878         case PS_TASK:
01879           return(rsbac_ta_list_lol_subexist(ta_number, task_set_handle, &id.task_set, &member.task));
01880         case PS_TP:
01881           return(rsbac_ta_list_lol_subexist(ta_number, tp_set_handle, &id.tp_set, &member.tp));
01882         case PS_RU:
01883           return(rsbac_ta_list_lol_subexist(ta_number, ru_set_handle, &id.ru_set, &member.ru));
01884         case PS_PP:
01885           return(rsbac_ta_list_lol_subexist(ta_number, pp_set_handle, &id.pp_set, &member.pp));
01886         case PS_IN_PP:
01887           return(rsbac_ta_list_lol_subexist(ta_number, in_pp_set_handle, &id.in_pp_set, &member.pp));
01888         case PS_OUT_PP:
01889           return(rsbac_ta_list_lol_subexist(ta_number, out_pp_set_handle, &id.out_pp_set, &member.pp));
01890         default:
01891           return(FALSE);
01892       }
01893   }
01894 
01895 /* rsbac_pm_pp_subset */
01896 /* Return truth value, whether pp_set is subset of in_pp_set */
01897 
01898 rsbac_boolean_t  rsbac_pm_pp_subset (rsbac_pm_pp_set_id_t    pp_set,
01899                              rsbac_pm_in_pp_set_id_t in_pp_set)
01900   {
01901            rsbac_pm_purpose_id_t          * pp_array;
01902            long                             count;
01903            u_long                           i;
01904            rsbac_boolean_t                          result = TRUE;
01905 
01906     if(!pp_set || !in_pp_set)
01907       return(FALSE);
01908 
01909     /* get all pp_set members */
01910     count = rsbac_list_lol_get_all_subdesc(pp_set_handle, &pp_set, (void **) &pp_array);
01911     if(count < 0)
01912       return FALSE;
01913     if(!count)
01914       return TRUE;
01915     if(!rsbac_list_lol_exist(in_pp_set_handle, &in_pp_set))
01916       {
01917         rsbac_vfree(pp_array);
01918         return TRUE;
01919       }
01920     /* check all members in in_pp_set */
01921     for(i=0; i< count; i++)
01922       {
01923         if(!rsbac_list_lol_subexist(in_pp_set_handle, &in_pp_set, &pp_array[i]))
01924           {
01925             result = FALSE;
01926             break;
01927           }
01928       }
01929     rsbac_vfree(pp_array);
01930     return result;
01931   }
01932 
01933 /* rsbac_pm_pp_superset */
01934 /* Return truth value, whether pp_set is superset of out_pp_set */
01935 
01936 rsbac_boolean_t  rsbac_pm_pp_superset (rsbac_pm_pp_set_id_t    pp_set,
01937                                rsbac_pm_out_pp_set_id_t out_pp_set)
01938   {
01939            rsbac_pm_purpose_id_t          * pp_array;
01940            long                             count;
01941            u_long                           i;
01942            rsbac_boolean_t                          result = TRUE;
01943 
01944     if(!pp_set)
01945       return(FALSE);
01946     if(!out_pp_set)
01947       return(TRUE);
01948     if(!rsbac_list_lol_exist(pp_set_handle, &pp_set))
01949       return FALSE;
01950 
01951     /* get all pp_set members */
01952     count = rsbac_list_lol_get_all_subdesc(out_pp_set_handle, &out_pp_set, (void **) &pp_array);
01953     if(count <= 0)
01954       return TRUE;
01955     /* check all members in in_pp_set */
01956     for(i=0; i< count; i++)
01957       {
01958         if(!rsbac_list_lol_subexist(pp_set_handle, &pp_set, &pp_array[i]))
01959           {
01960             result = FALSE;
01961             break;
01962           }
01963       }
01964     rsbac_vfree(pp_array);
01965     return result;
01966   }
01967 
01968 /* rsbac_pm_pp_only */
01969 /* Return truth value, if there is no other item in out_pp_set than purpose */
01970 
01971 rsbac_boolean_t  rsbac_pm_pp_only (rsbac_pm_purpose_id_t    purpose,
01972                            rsbac_pm_out_pp_set_id_t out_pp_set)
01973   {
01974            long                             count;
01975 
01976     if(!out_pp_set)
01977       return(TRUE);
01978 
01979     /* get number of pp_set members */
01980     count = rsbac_list_lol_subcount(out_pp_set_handle, &out_pp_set);
01981     if(count <= 0)
01982       return TRUE;
01983     if(count == 1)
01984       return rsbac_list_lol_subexist(out_pp_set_handle, &out_pp_set, &purpose);
01985     else
01986       return FALSE;
01987   }
01988 
01989 /* rsbac_pm_pp_intersec */
01990 /* Create intersection of pp_set and in_pp_set in in_pp_set */
01991 /* If in_pp_set does not exist, it is created with all members of pp_set */
01992 /* If pp_set does not exist or one of them is invalid, an error is returned */
01993 
01994 int rsbac_pm_pp_intersec (rsbac_pm_pp_set_id_t      pp_set,
01995                           rsbac_pm_in_pp_set_id_t   in_pp_set)
01996   {
01997     rsbac_pm_purpose_id_t          * pp_array;
01998     long                             count;
01999     u_long                           i;
02000 
02001     if(!rsbac_list_lol_exist(pp_set_handle, &pp_set))
02002       return -RSBAC_EINVALIDVALUE;
02003 
02004     if(!rsbac_list_lol_exist(in_pp_set_handle, &in_pp_set))
02005       { /* in_pp_set not found -> try to create and fill with pp_set */
02006         if((count = rsbac_list_lol_add(in_pp_set_handle, &in_pp_set, NULL)))
02007           return count;
02008         /* creation successful -> copy list */
02009         /* get all pp_set members */
02010         count = rsbac_list_lol_get_all_subdesc(pp_set_handle, &pp_set, (void **) &pp_array);
02011         if(count <= 0)
02012           return count;
02013         for(i=0; i < count; i++)
02014           {
02015             rsbac_list_lol_subadd(in_pp_set_handle, &in_pp_set, &pp_array[i], NULL);
02016           }
02017         rsbac_vfree(pp_array);
02018       }
02019     else
02020       { /* in_pp_set exists -> remove all members not in pp_set */
02021         /* get all in_pp_set members */
02022         count = rsbac_list_lol_get_all_subdesc(in_pp_set_handle, &in_pp_set, (void **) &pp_array);
02023         if(count <= 0)
02024           return count;
02025         for(i=0; i < count; i++)
02026           {
02027             if(!rsbac_list_lol_subexist(pp_set_handle, &pp_set, &pp_array[i]))
02028               rsbac_list_lol_subremove(in_pp_set_handle, &in_pp_set, &pp_array[i]);
02029           }
02030         rsbac_vfree(pp_array);
02031       }
02032     return 0;
02033   }
02034 
02035 /* rsbac_pm_pp_union */
02036 /* Create union of pp_set and out_pp_set in out_pp_set
02037  * If out_pp_set does not exist, it is created with all members of pp_set
02038  * If pp_set does not exist or one of them is invalid, an error is returned */
02039 
02040 int rsbac_pm_pp_union (rsbac_pm_pp_set_id_t      pp_set,
02041                        rsbac_pm_out_pp_set_id_t   out_pp_set)
02042   {
02043     rsbac_pm_purpose_id_t          * pp_array;
02044     long                             count;
02045     u_long                           i;
02046     
02047     /* check, whether set-id pp_set exists */
02048     if(!rsbac_list_lol_exist(pp_set_handle, &pp_set))
02049       return -RSBAC_EINVALIDVALUE;
02050 
02051     if(!rsbac_list_lol_exist(out_pp_set_handle, &out_pp_set))
02052       { /* out_pp_set not found -> try to create */
02053         count = rsbac_list_lol_add(out_pp_set_handle, &out_pp_set, NULL);
02054         if(count)
02055           return count;
02056       }
02057     /* out_pp_set exists -> add all members in pp_set */
02058     /* get all pp_set members */
02059     count = rsbac_list_lol_get_all_subdesc(pp_set_handle, &pp_set, (void **) &pp_array);
02060     if(count <= 0)
02061       return count;
02062     for(i=0; i < count; i++)
02063       {
02064         rsbac_list_lol_subadd(out_pp_set_handle, &out_pp_set, &pp_array[i], NULL);
02065       }
02066     rsbac_vfree(pp_array);
02067     return 0;
02068   }
02069 
02070 /* rsbac_pm_create_set */
02071 /* Create a new set of given type set, using id id. Using any other set */
02072 /* function for a set id without creating this set returns an error.    */
02073 /* To empty an existing set use rsbac_pm_clear_set.                     */
02074 
02075 int rsbac_pm_create_set(
02076         rsbac_list_ta_number_t ta_number,
02077   enum  rsbac_pm_set_t set,
02078   union rsbac_pm_set_id_t id)
02079   {
02080     switch (set)
02081       {
02082         case PS_TASK:
02083 /*
02084 #ifdef CONFIG_RSBAC_DEBUG
02085           if (rsbac_debug_ds_pm)
02086             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating task set\n");
02087 #endif
02088 */
02089           if(rsbac_ta_list_lol_exist(ta_number, task_set_handle, &id.task_set))
02090             return -RSBAC_EEXISTS;
02091           return rsbac_ta_list_lol_add_ttl(ta_number, task_set_handle, 0, &id.task_set, NULL);
02092         case PS_TP:
02093 /*
02094 #ifdef CONFIG_RSBAC_DEBUG
02095           if (rsbac_debug_ds_pm)
02096             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating tp set\n");
02097 #endif
02098 */
02099           if(rsbac_ta_list_lol_exist(ta_number, tp_set_handle, &id.tp_set))
02100             return -RSBAC_EEXISTS;
02101           return rsbac_ta_list_lol_add_ttl(ta_number, tp_set_handle, 0, &id.tp_set, NULL);
02102         case PS_RU:
02103 /*
02104 #ifdef CONFIG_RSBAC_DEBUG
02105           if (rsbac_debug_ds_pm)
02106             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating ru set\n");
02107 #endif
02108 */
02109           if(rsbac_ta_list_lol_exist(ta_number, ru_set_handle, &id.ru_set))
02110             return -RSBAC_EEXISTS;
02111           return rsbac_ta_list_lol_add_ttl(ta_number, ru_set_handle, 0, &id.ru_set, NULL);
02112         case PS_PP:
02113 /*
02114 #ifdef CONFIG_RSBAC_DEBUG
02115           if (rsbac_debug_ds_pm)
02116             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating pp set\n");
02117 #endif
02118 */
02119           if(rsbac_ta_list_lol_exist(ta_number, pp_set_handle, &id.pp_set))
02120             return -RSBAC_EEXISTS;
02121           return rsbac_ta_list_lol_add_ttl(ta_number, pp_set_handle, 0, &id.pp_set, NULL);
02122         case PS_IN_PP:
02123 /*
02124 #ifdef CONFIG_RSBAC_DEBUG
02125           if (rsbac_debug_ds_pm)
02126             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating in_pp set\n");
02127 #endif
02128 */
02129           if(rsbac_ta_list_lol_exist(ta_number, in_pp_set_handle, &id.in_pp_set))
02130             return -RSBAC_EEXISTS;
02131           return rsbac_ta_list_lol_add_ttl(ta_number, in_pp_set_handle, 0, &id.in_pp_set, NULL);
02132         case PS_OUT_PP:
02133 /*
02134 #ifdef CONFIG_RSBAC_DEBUG
02135           if (rsbac_debug_ds_pm)
02136             printk(KERN_DEBUG "rsbac_pm_create_set(): Creating out_pp set\n");
02137 #endif
02138 */
02139           if(rsbac_ta_list_lol_exist(ta_number, out_pp_set_handle, &id.out_pp_set))
02140             return -RSBAC_EEXISTS;
02141           return rsbac_ta_list_lol_add_ttl(ta_number, out_pp_set_handle, 0, &id.out_pp_set, NULL);
02142 
02143         default:
02144           return(-RSBAC_EINVALIDTARGET);          
02145       }
02146   }
02147 
02148 /* rsbac_pm_set_exist */
02149 /* Return rsbac_boolean_t value whether set exists */
02150 
02151 rsbac_boolean_t rsbac_pm_set_exist (
02152         rsbac_list_ta_number_t ta_number,
02153   enum  rsbac_pm_set_t set,
02154   union rsbac_pm_set_id_t id)
02155   {
02156     switch (set)
02157       {
02158         case PS_TASK:
02159           return rsbac_ta_list_lol_exist(ta_number, task_set_handle, &id.task_set);
02160         case PS_TP:
02161           return rsbac_ta_list_lol_exist(ta_number, tp_set_handle, &id.tp_set);
02162         case PS_RU:
02163           return rsbac_ta_list_lol_exist(ta_number, ru_set_handle, &id.ru_set);
02164         case PS_PP:
02165           return rsbac_ta_list_lol_exist(ta_number, pp_set_handle, &id.pp_set);
02166         case PS_IN_PP:
02167           return rsbac_ta_list_lol_exist(ta_number, in_pp_set_handle, &id.in_pp_set);
02168         case PS_OUT_PP:
02169           return rsbac_ta_list_lol_exist(ta_number, out_pp_set_handle, &id.out_pp_set);
02170 
02171         default:
02172           return FALSE;
02173       }
02174   }
02175 
02176 /* rsbac_pm_remove_set */
02177 /* Remove a full set. After this call the given id can only be used for */
02178 /* creating a new set, anything else returns an error.                  */
02179 /* To empty an existing set use rsbac_pm_clear_set.                     */
02180 /* Caution: Writing to disk is done in the remove_item functions!       */
02181 
02182 int rsbac_pm_remove_set(
02183         rsbac_list_ta_number_t ta_number,
02184   enum  rsbac_pm_set_t set,
02185   union rsbac_pm_set_id_t id)
02186   {
02187     switch (set)
02188       {
02189         case PS_TASK:
02190           return rsbac_ta_list_lol_remove(ta_number, task_set_handle, &id.task_set);
02191         case PS_TP:
02192           return rsbac_ta_list_lol_remove(ta_number, tp_set_handle, &id.tp_set);
02193         case PS_RU:
02194           return rsbac_ta_list_lol_remove(ta_number, ru_set_handle, &id.ru_set);
02195         case PS_PP:
02196           return rsbac_ta_list_lol_remove(ta_number, pp_set_handle, &id.pp_set);
02197         case PS_IN_PP:
02198           return rsbac_ta_list_lol_remove(ta_number, in_pp_set_handle, &id.in_pp_set);
02199         case PS_OUT_PP:
02200           return rsbac_ta_list_lol_remove(ta_number, out_pp_set_handle, &id.out_pp_set);
02201 
02202         default:
02203           return -RSBAC_EINVALIDTARGET;
02204       }
02205   }
02206 
02207 /**************/
02208 /* Main lists */
02209 /**************/
02210 
02211 /* rsbac_pm_get_data() and rsbac_pm_set_data() change single data values.   */
02212 /* rsbac_pm_add_target() adds a new list item and sets all data values as   */
02213 /* given. rsbac_pm_remove_target() removes an item.                         */
02214 
02215 /* A rsbac_pm_[sg]et_data() call for a non-existing target will return an   */
02216 /* error.*/
02217 /* Invalid parameter combinations return an error.                          */
02218 
02219 int rsbac_pm_get_data(
02220         rsbac_list_ta_number_t ta_number,
02221   enum  rsbac_pm_target_t target,
02222   union rsbac_pm_target_id_t tid,
02223   enum  rsbac_pm_data_t data,
02224   union rsbac_pm_data_value_t * value)
02225     { 
02226       int err = 0;
02227     
02228       if (!value)
02229         return(-RSBAC_EINVALIDVALUE);
02230 
02231       switch (target)
02232         {
02233           case PMT_TASK:
02234             {
02235               struct rsbac_pm_task_data_t all_data;
02236 
02237 /*
02238 #ifdef CONFIG_RSBAC_DEBUG
02239               if (rsbac_debug_ds_pm)
02240                 printk(KERN_DEBUG
02241                        "rsbac_pm_get_data(): Getting task data\n");
02242 #endif
02243 */
02244               err = rsbac_ta_list_get_data_ttl(ta_number, task_handle,
02245                                                NULL, &tid.task, &all_data);
02246               if(err)
02247                 return err;
02248 
02249               switch (data)
02250                 {
02251                   case PD_purpose:
02252                     value->purpose = all_data.purpose;
02253                     break;
02254                   case PD_tp_set:
02255                     value->tp_set = all_data.tp_set;
02256                     break;
02257                   case PD_ru_set:
02258                     value->ru_set = all_data.ru_set;
02259                     break;
02260                   default:
02261                     return -RSBAC_EINVALIDATTR;
02262                 }
02263               return 0;
02264             }
02265 
02266           case PMT_CLASS:
02267             {
02268               struct rsbac_pm_class_data_t all_data;
02269 
02270 /*
02271 #ifdef CONFIG_RSBAC_DEBUG
02272               if (rsbac_debug_ds_pm)
02273                 printk(KERN_DEBUG
02274                        "rsbac_pm_get_data(): Getting class data\n");
02275 #endif
02276 */
02277               err = rsbac_ta_list_get_data_ttl(ta_number, class_handle,
02278                                                NULL, &tid.object_class, &all_data);
02279               if(err)
02280                 return err;
02281 
02282               switch (data)
02283                 {
02284                   case PD_pp_set:
02285                     value->pp_set = all_data.pp_set;
02286                     break;
02287                   default:
02288                     return -RSBAC_EINVALIDATTR;
02289                 }
02290               return 0;
02291             }
02292             
02293           case PMT_NA:
02294             {
02295               struct rsbac_pm_na_data_t all_data;
02296 
02297 /*
02298 #ifdef CONFIG_RSBAC_DEBUG
02299               if (rsbac_debug_ds_pm)
02300                 printk(KERN_DEBUG
02301                        "rsbac_pm_get_data(): Getting na data\n");
02302 #endif
02303 */
02304               err = rsbac_ta_list_get_data_ttl(ta_number, na_handle,
02305                                                NULL, &tid.na, &all_data);
02306               if(err)
02307                 return err;
02308 
02309               switch (data)
02310                 {
02311                   case PD_task:
02312                      value->task = all_data.task;
02313                     break;
02314                   case PD_class:
02315                     value->object_class = all_data.object_class;
02316                     break;
02317                   case PD_tp:
02318                     value->tp = all_data.tp;
02319                     break;
02320                   case PD_accesses:
02321                     value->accesses = all_data.accesses;
02322                     break;
02323                   default:
02324                     return -RSBAC_EINVALIDATTR;
02325                 }
02326               return 0;
02327             }
02328             
02329           case PMT_CS:
02330             {
02331               struct rsbac_pm_cs_data_t all_data;
02332 
02333 /*
02334 #ifdef CONFIG_RSBAC_DEBUG
02335               if (rsbac_debug_ds_pm)
02336                 printk(KERN_DEBUG
02337                        "rsbac_pm_get_data(): Getting cs data\n");
02338 #endif
02339 */
02340               err = rsbac_ta_list_get_data_ttl(ta_number, cs_handle,
02341                                                NULL, &tid.cs, &all_data);
02342               if(err)
02343                 return err;
02344 
02345               switch (data)
02346                 {
02347                   case PD_purpose:
02348                     value->purpose = all_data.purpose;
02349                     break;
02350                   case PD_file:
02351                     value->file = all_data.file;
02352                     break;
02353                   default:
02354                     return -RSBAC_EINVALIDATTR;
02355                 }
02356               return 0;
02357             }
02358             
02359           case PMT_TP:
02360             {
02361               struct rsbac_pm_tp_data_t all_data;
02362 
02363 /*
02364 #ifdef CONFIG_RSBAC_DEBUG
02365               if (rsbac_debug_ds_pm)
02366                 printk(KERN_DEBUG
02367                        "rsbac_pm_get_data(): Getting tp data\n");
02368 #endif
02369 */
02370               err = rsbac_ta_list_get_data_ttl(ta_number, tp_handle,
02371                                                NULL, &tid.tp, &all_data);
02372               if(err)
02373                 return err;
02374 
02375               switch (data)
02376                 {
02377                   case PD_tp:
02378                     value->tp = all_data.id;
02379                     break;
02380                   default:
02381                     return -RSBAC_EINVALIDATTR;
02382                 }
02383               return 0;
02384             }
02385             
02386           case PMT_PP:
02387             {
02388               struct rsbac_pm_pp_data_t all_data;
02389 
02390 /*
02391 #ifdef CONFIG_RSBAC_DEBUG
02392               if (rsbac_debug_ds_pm)
02393                 printk(KERN_DEBUG
02394                        "rsbac_pm_get_data(): Getting pp data\n");
02395 #endif
02396 */
02397               err = rsbac_ta_list_get_data_ttl(ta_number, pp_handle,
02398                                                NULL, &tid.pp, &all_data);
02399               if(err)
02400                 return err;
02401 
02402               switch (data)
02403                 {
02404                   case PD_purpose:
02405                     value->purpose = all_data.id;
02406                     break;
02407                   case PD_def_class:
02408                     value->def_class = all_data.def_class;
02409                     break;
02410                   default:
02411                     return -RSBAC_EINVALIDATTR;
02412                 }
02413               return 0;
02414             }
02415             
02416           case PMT_TKT:
02417             {
02418               struct rsbac_pm_tkt_data_t all_data;
02419 
02420 /*
02421 #ifdef CONFIG_RSBAC_DEBUG
02422               if (rsbac_debug_ds_pm)
02423                 printk(KERN_DEBUG
02424                        "rsbac_pm_get_data(): Getting tkt data\n");
02425 #endif
02426 */
02427               err = rsbac_ta_list_get_data_ttl(ta_number, tkt_handle,
02428                                                NULL, &tid.tkt, &all_data);
02429               if(err)
02430                 return err;
02431 
02432               switch (data)
02433                 {
02434                   case PD_issuer:
02435                     value->issuer = all_data.issuer;
02436                     break;
02437                   case PD_function_type:
02438                     value->function_type = all_data.function_type;
02439                     break;
02440                   case PD_function_param:
02441                     value->function_param = all_data.function_param;
02442                     break;
02443                   case PD_valid_until:
02444                     value->valid_until = all_data.valid_until;
02445                     break;
02446                   default:
02447                     return -RSBAC_EINVALIDATTR;
02448                 }
02449               return 0;
02450             }
02451 
02452           /* switch target: no valid target */
02453           default:  
02454             return(-RSBAC_EINVALIDTARGET);
02455         }
02456     };      /* end of rsbac_pm_get_data() */
02457 
02458 /************************************************************************** */
02459 
02460 int rsbac_pm_get_all_data(
02461         rsbac_list_ta_number_t ta_number,
02462   enum  rsbac_pm_target_t target,
02463   union rsbac_pm_target_id_t tid,
02464   union rsbac_pm_all_data_value_t * value)
02465     { 
02466       if (!value)
02467         return(-RSBAC_EINVALIDVALUE);
02468       switch (target)
02469         {
02470           case PMT_TASK:
02471 /*
02472 #ifdef CONFIG_RSBAC_DEBUG
02473             if (rsbac_debug_ds_pm)
02474               printk(KERN_DEBUG
02475                      "rsbac_pm_get_data(): Getting task data\n");
02476 #endif
02477 */
02478             return rsbac_ta_list_get_data_ttl(ta_number, task_handle,
02479                                               NULL, &tid.task, &value->task);
02480 
02481           case PMT_CLASS:
02482 /*
02483 #ifdef CONFIG_RSBAC_DEBUG
02484             if (rsbac_debug_ds_pm)
02485               printk(KERN_DEBUG
02486                      "rsbac_pm_get_data(): Getting class data\n");
02487 #endif
02488 */
02489             return rsbac_ta_list_get_data_ttl(ta_number, class_handle,
02490                                               NULL, &tid.object_class, &value->object_class);
02491 
02492           case PMT_NA:
02493 /*
02494 #ifdef CONFIG_RSBAC_DEBUG
02495             if (rsbac_debug_ds_pm) 
02496               printk(KERN_DEBUG
02497                      "rsbac_pm_get_data(): Getting na data\n");
02498 #endif
02499 */
02500             return rsbac_ta_list_get_data_ttl(ta_number, na_handle,
02501                                               NULL, &tid.na, &value->na);
02502 
02503           case PMT_CS:
02504 /*
02505 #ifdef CONFIG_RSBAC_DEBUG
02506             if (rsbac_debug_ds_pm)
02507               printk(KERN_DEBUG
02508                      "rsbac_pm_get_data(): Getting cs data\n");
02509 #endif
02510 */
02511             return rsbac_ta_list_get_data_ttl(ta_number, cs_handle,
02512                                               NULL, &tid.cs, &value->cs);
02513 
02514           case PMT_TP:
02515 /*
02516 #ifdef CONFIG_RSBAC_DEBUG
02517             if (rsbac_debug_ds_pm)
02518               printk(KERN_DEBUG
02519                      "rsbac_pm_get_data(): Getting tp data\n");
02520 #endif
02521 */
02522             return rsbac_ta_list_get_data_ttl(ta_number, tp_handle,
02523                                               NULL, &tid.tp, &value->tp);
02524 
02525           case PMT_PP:
02526 /*
02527 #ifdef CONFIG_RSBAC_DEBUG
02528             if (rsbac_debug_ds_pm)
02529               printk(KERN_DEBUG
02530                      "rsbac_pm_get_data(): Getting pp data\n");
02531 #endif
02532 */
02533             return rsbac_ta_list_get_data_ttl(ta_number, pp_handle,
02534                                               NULL, &tid.pp, &value->pp);
02535 
02536           case PMT_TKT:
02537 /*
02538 #ifdef CONFIG_RSBAC_DEBUG
02539             if (rsbac_debug_ds_pm)
02540               printk(KERN_DEBUG
02541                      "rsbac_pm_get_data(): Getting tkt data\n");
02542 #endif
02543 */
02544             return rsbac_ta_list_get_data_ttl(ta_number, tkt_handle,
02545                                               NULL, &tid.tkt, &value->tkt);
02546 
02547           /* switch target: no valid target */
02548           default:  
02549             return(-RSBAC_EINVALIDTARGET);
02550         }
02551     }      /* end of rsbac_pm_get_all_data() */
02552 
02553 /************************************************************************** */
02554 
02555 rsbac_boolean_t rsbac_pm_exists(
02556         rsbac_list_ta_number_t ta_number,
02557   enum  rsbac_pm_target_t target,
02558   union rsbac_pm_target_id_t tid)
02559     { 
02560       switch (target)
02561         {
02562           case PMT_TASK:
02563             return rsbac_ta_list_exist(ta_number, task_handle, &tid.task);
02564 
02565           case PMT_CLASS:
02566             /* IPC and DEV classes always exist */
02567             if(   (tid.object_class == RSBAC_PM_IPC_OBJECT_CLASS_ID)
02568                || (tid.object_class == RSBAC_PM_DEV_OBJECT_CLASS_ID))
02569               return(TRUE);
02570             return rsbac_ta_list_exist(ta_number, class_handle, &tid.object_class);
02571 
02572           case PMT_NA:
02573             return rsbac_ta_list_exist(ta_number, na_handle, &tid.na);
02574 
02575           case PMT_CS:
02576             return rsbac_ta_list_exist(ta_number, cs_handle, &tid.cs);
02577 
02578           case PMT_TP:
02579             return rsbac_ta_list_exist(ta_number, tp_handle, &tid.tp);
02580 
02581           case PMT_PP:
02582             return rsbac_ta_list_exist(ta_number, pp_handle, &tid.pp);
02583 
02584           case PMT_TKT:
02585             {
02586               struct rsbac_pm_tkt_data_t all_data;
02587 
02588               if(rsbac_ta_list_get_data_ttl(ta_number, tkt_handle,
02589                                             NULL, &tid.tkt, &all_data))
02590                 return FALSE;
02591 
02592               /* ticket too old? -> remove it and return FALSE */
02593               {
02594                 if(all_data.valid_until < RSBAC_CURRENT_TIME)
02595                   {
02596                     rsbac_pm_pp_set_id_t pp_set = -tid.tkt;
02597 
02598                     if(rsbac_ta_list_lol_exist(ta_number, pp_set_handle, &pp_set))
02599                       rsbac_ta_list_lol_remove(ta_number, pp_set_handle, &pp_set);
02600                     rsbac_ta_list_remove(ta_number, tkt_handle, &tid.tkt);
02601                     return(FALSE);
02602                   }
02603                 else
02604                   return TRUE;
02605               }
02606             }
02607 
02608           /* switch target: no valid target */
02609           default:  
02610             printk(KERN_WARNING
02611                    "rsbac_pm_exists(): Invalid target!\n");
02612             return FALSE;
02613         }
02614     }      /* end of rsbac_pm_exists() */
02615 
02616 /************************************************************************** */
02617 
02618 int rsbac_pm_set_data(
02619         rsbac_list_ta_number_t ta_number,
02620   enum  rsbac_pm_target_t target,
02621   union rsbac_pm_target_id_t tid,
02622   enum  rsbac_pm_data_t data,
02623   union rsbac_pm_data_value_t value)
02624     { 
02625       switch (target)
02626         {
02627           case PMT_TASK:
02628             {
02629               struct rsbac_pm_task_data_t all_data;
02630                      int                  err;
02631 
02632 /*
02633 #ifdef CONFIG_RSBAC_DEBUG
02634               if (rsbac_debug_ds_pm)
02635                 printk(KERN_DEBUG
02636                        "rsbac_pm_set_data(): Setting task data\n");
02637 #endif
02638 */
02639               err = rsbac_ta_list_get_data_ttl(ta_number, task_handle,
02640                                                NULL, &tid.task, &all_data);
02641               if(err)
02642                 return err;
02643 
02644               switch (data)
02645                 {
02646                   case PD_purpose:
02647                     all_data.purpose = value.purpose;
02648                     break;
02649                   case PD_tp_set:
02650                     all_data.tp_set = value.tp_set;
02651                     break;
02652                   case PD_ru_set:
02653                     all_data.ru_set = value.ru_set;
02654                     break;
02655                   default:
02656                     return -RSBAC_EINVALIDATTR;
02657                 }
02658               err = rsbac_ta_list_add_ttl(ta_number, task_handle, 0, &tid.task, &all_data);
02659               return err;
02660             }
02661 
02662           case PMT_CLASS:
02663             {
02664               struct rsbac_pm_class_data_t all_data;
02665                      int                   err;
02666 
02667 /*
02668 #ifdef CONFIG_RSBAC_DEBUG
02669               if (rsbac_debug_ds_pm)
02670                 printk(KERN_DEBUG
02671                        "rsbac_pm_set_data(): Setting class data\n");
02672 #endif
02673 */
02674               err = rsbac_ta_list_get_data_ttl(ta_number, class_handle,
02675                                                NULL, &tid.object_class, &all_data);
02676               if(err)
02677                 return err;
02678 
02679               switch (data)
02680                 {
02681                   case PD_pp_set:
02682                     all_data.pp_set = value.pp_set;
02683                     break;
02684                   default:
02685                     return -RSBAC_EINVALIDATTR;
02686                 }
02687               err = rsbac_ta_list_add_ttl(ta_number, class_handle, 0, &tid.object_class, &all_data);
02688               return err;
02689             }
02690 
02691           case PMT_NA:
02692             {
02693               struct rsbac_pm_na_data_t all_data;
02694                      int                err;
02695 
02696 /*
02697 #ifdef CONFIG_RSBAC_DEBUG
02698               if (rsbac_debug_ds_pm)
02699                 printk(KERN_DEBUG
02700                        "rsbac_pm_set_data(): Setting na data\n");
02701 #endif
02702 */
02703               err = rsbac_ta_list_get_data_ttl(ta_number, na_handle,
02704                                                NULL, &tid.na, &all_data);
02705               if(err)
02706                 return err;
02707 
02708               switch (data)
02709                 {
02710                   case PD_task:
02711                     all_data.task = value.task;
02712                     break;
02713                   case PD_class:
02714                     all_data.object_class = value.object_class;
02715                     break;
02716                   case PD_tp:
02717                     all_data.tp = value.tp;
02718                     break;
02719                   case PD_accesses:
02720                     all_data.accesses = value.accesses;
02721                     break;
02722                   default:
02723                     return -RSBAC_EINVALIDATTR;
02724                 }
02725               err = rsbac_ta_list_add_ttl(ta_number, na_handle, 0, &tid.na, &all_data);
02726               return err;
02727             }
02728 
02729           case PMT_CS:
02730             {
02731               struct rsbac_pm_cs_data_t all_data;
02732                      int                err;
02733 
02734 /*
02735 #ifdef CONFIG_RSBAC_DEBUG
02736               if (rsbac_debug_ds_pm)
02737                 printk(KERN_DEBUG
02738                        "rsbac_pm_set_data(): Setting cs data\n");
02739 #endif
02740 */
02741               err = rsbac_ta_list_get_data_ttl(ta_number, cs_handle,
02742                                                NULL, &tid.cs, &all_data);
02743               if(err)
02744                 return err;
02745 
02746               switch (data)
02747                 {
02748                   case PD_purpose:
02749                     all_data.purpose = value.purpose;
02750                     break;
02751                   case PD_file:
02752                     all_data.file = value.file;
02753                     break;
02754                   default:
02755                     return -RSBAC_EINVALIDATTR;
02756                 }
02757               err = rsbac_ta_list_add_ttl(ta_number, cs_handle, 0, &tid.cs, &all_data);
02758               return err;
02759             }
02760 
02761           case PMT_TP:
02762             return -RSBAC_EINVALIDATTR;
02763 
02764           case PMT_PP:
02765             {
02766               struct rsbac_pm_pp_data_t all_data;
02767                      int                err;
02768 
02769 /*
02770 #ifdef CONFIG_RSBAC_DEBUG
02771               if (rsbac_debug_ds_pm)
02772                 printk(KERN_DEBUG
02773                        "rsbac_pm_set_data(): Setting pp data\n");
02774 #endif
02775 */
02776               err = rsbac_ta_list_get_data_ttl(ta_number, pp_handle,
02777                                                NULL, &tid.pp, &all_data);
02778               if(err)
02779                 return err;
02780 
02781               switch (data)
02782                 {
02783                   case PD_def_class:
02784                     all_data.def_class = value.def_class;
02785                     break;
02786                   default:
02787                     return -RSBAC_EINVALIDATTR;
02788                 }
02789               err = rsbac_ta_list_add_ttl(ta_number, pp_handle, 0, &tid.pp, &all_data);
02790               return err;
02791             }
02792 
02793           case PMT_TKT:
02794             {
02795               struct rsbac_pm_tkt_data_t all_data;
02796                      int                 err;
02797 
02798 /*
02799 #ifdef CONFIG_RSBAC_DEBUG
02800               if (rsbac_debug_ds_pm)
02801                 printk(KERN_DEBUG
02802                        "rsbac_pm_set_data(): Setting tkt data\n");
02803 #endif
02804 */
02805               err = rsbac_ta_list_get_data_ttl(ta_number, tkt_handle,
02806                                                NULL, &tid.tkt, &all_data);
02807               if(err)
02808                 return err;
02809 
02810               switch (data)
02811                 {
02812                   case PD_issuer:
02813                     all_data.issuer = value.issuer;
02814                     break;
02815                   case PD_function_type:
02816                     all_data.function_type = value.function_type;
02817                     break;
02818                   case PD_function_param:
02819                     all_data.function_param = value.function_param;
02820                     break;
02821                   case PD_valid_until:
02822                     all_data.valid_until = value.valid_until;
02823                     break;
02824                   default:
02825                     return -RSBAC_EINVALIDATTR;
02826                 }
02827               err = rsbac_ta_list_add_ttl(ta_number, tkt_handle, 0, &tid.tkt, &all_data);
02828               return err;
02829             }
02830 
02831           /* switch target: no valid target */
02832           default:  
02833             return(-RSBAC_EINVALIDTARGET);
02834         }
02835     }      /* end of rsbac_pm_set_data() */
02836 
02837 /************************************************************************** */
02838 
02839 int rsbac_pm_add_target(
02840         rsbac_list_ta_number_t ta_number,
02841   enum  rsbac_pm_target_t target,
02842   union rsbac_pm_all_data_value_t data)
02843     { 
02844       switch (target)
02845         {
02846           case PMT_TASK:
02847 /*
02848 #ifdef CONFIG_RSBAC_DEBUG
02849             if (rsbac_debug_ds_pm)
02850               printk(KERN_DEBUG
02851                      "rsbac_pm_add_target(): Adding task item\n");
02852 #endif
02853 */
02854             return rsbac_ta_list_add_ttl(ta_number, task_handle, 0, &data.task.id, &data.task);
02855             
02856           case PMT_CLASS:
02857 /*
02858 #ifdef CONFIG_RSBAC_DEBUG
02859             if (rsbac_debug_ds_pm)
02860               printk(KERN_DEBUG
02861                      "rsbac_pm_add_target(): Adding class item\n");
02862 #endif
02863 */
02864             return rsbac_ta_list_add_ttl(ta_number, class_handle, 0, &data.object_class.id, &data.object_class);
02865 
02866           case PMT_NA:
02867             {
02868               struct rsbac_pm_na_id_t na_id;
02869 
02870 /*
02871 #ifdef CONFIG_RSBAC_DEBUG
02872               if (rsbac_debug_ds_pm)
02873                 printk(KERN_DEBUG
02874                        "rsbac_pm_add_target(): Adding na item\n");
02875 #endif
02876 */
02877               na_id.task = data.na.task;
02878               na_id.object_class = data.na.object_class;
02879               na_id.tp = data.na.tp;
02880               return rsbac_ta_list_add_ttl(ta_number, na_handle, 0, &na_id, &data.na);
02881             }
02882 
02883           case PMT_CS:
02884             {
02885               struct rsbac_pm_cs_id_t cs_id;
02886 
02887 /*
02888 #ifdef CONFIG_RSBAC_DEBUG
02889               if (rsbac_debug_ds_pm)
02890                 printk(KERN_DEBUG
02891                        "rsbac_pm_add_target(): Adding cs item\n");
02892 #endif
02893 */
02894               cs_id.purpose = data.cs.purpose;
02895               cs_id.file = data.cs.file;
02896               return rsbac_ta_list_add_ttl(ta_number, cs_handle, 0, &cs_id, &data.cs);
02897             }
02898 
02899           case PMT_TP:
02900 /*
02901 #ifdef CONFIG_RSBAC_DEBUG
02902             if (rsbac_debug_ds_pm)
02903               printk(KERN_DEBUG
02904                      "rsbac_pm_add_target(): Adding tp item\n");
02905 #endif
02906 */
02907             return rsbac_ta_list_add_ttl(ta_number, tp_handle, 0, &data.tp.id, &data.tp);
02908 
02909           case PMT_PP:
02910 /*
02911 #ifdef CONFIG_RSBAC_DEBUG
02912             if (rsbac_debug_ds_pm)
02913               printk(KERN_DEBUG
02914                      "rsbac_pm_add_target(): Adding pp item\n");
02915 #endif
02916 */
02917             return rsbac_ta_list_add_ttl(ta_number, pp_handle, 0, &data.pp.id, &data.pp);
02918 
02919           case PMT_TKT:
02920 /*
02921 #ifdef CONFIG_RSBAC_DEBUG
02922             if (rsbac_debug_ds_pm)
02923               printk(KERN_DEBUG
02924                      "rsbac_pm_add_target(): Adding tkt item\n");
02925 #endif
02926 */
02927             return rsbac_ta_list_add_ttl(ta_number, tkt_handle, 0, &data.tkt.id, &data.tkt);
02928 
02929           /* switch target: no valid target */
02930           default:  
02931             return(-RSBAC_EINVALIDTARGET);
02932         }
02933     }      /* end of rsbac_pm_add_target() */
02934 
02935 /************************************************************************** */
02936 
02937 int rsbac_pm_remove_target(
02938         rsbac_list_ta_number_t ta_number,
02939   enum  rsbac_pm_target_t target,
02940   union rsbac_pm_target_id_t tid)
02941     { 
02942       switch (target)
02943         {
02944           case PMT_TASK:
02945 /*
02946 #ifdef CONFIG_RSBAC_DEBUG
02947             if (rsbac_debug_ds_pm)
02948               printk(KERN_DEBUG
02949                      "rsbac_pm_remove_target(): Removing task data\n");
02950 #endif
02951 */
02952             return rsbac_ta_list_remove(ta_number, task_handle, &tid.task);
02953 
02954           case PMT_CLASS:
02955 /*
02956 #ifdef CONFIG_RSBAC_DEBUG
02957             if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
02958                         "rsbac_pm_remove_target(): Removing class data");
02959 #endif
02960 */
02961             return rsbac_ta_list_remove(ta_number, class_handle, &tid.object_class);
02962 
02963           case PMT_NA:
02964 /*
02965 #ifdef CONFIG_RSBAC_DEBUG
02966             if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
02967                         "rsbac_pm_remove_target(): Removing tp data");
02968 #endif
02969 */
02970             return rsbac_ta_list_remove(ta_number, na_handle, &tid.na);
02971 
02972           case PMT_CS:
02973 /*
02974 #ifdef CONFIG_RSBAC_DEBUG
02975             if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
02976                         "rsbac_pm_remove_target(): Removing cs data");
02977 #endif
02978 */
02979             return rsbac_ta_list_remove(ta_number, cs_handle, &tid.cs);
02980 
02981           case PMT_TP:
02982 /*
02983 #ifdef CONFIG_RSBAC_DEBUG
02984             if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
02985                         "rsbac_pm_remove_target(): Removing tp data");
02986 #endif
02987 */
02988             return rsbac_ta_list_remove(ta_number, tp_handle, &tid.tp);
02989 
02990           case PMT_PP:
02991 /*
02992 #ifdef CONFIG_RSBAC_DEBUG
02993             if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
02994                         "rsbac_pm_remove_target(): Removing pp data");
02995 #endif
02996 */
02997             return rsbac_ta_list_remove(ta_number, pp_handle, &tid.pp);
02998 
02999           case PMT_TKT:
03000             {
03001               rsbac_pm_pp_set_id_t pp_set = -tid.tkt;
03002 
03003 /*
03004 #ifdef CONFIG_RSBAC_DEBUG
03005               if (rsbac_debug_ds_pm) printk(KERN_DEBUG "%s\n",
03006                           "rsbac_pm_remove_target(): Removing tkt data");
03007 #endif
03008 */
03009               if(rsbac_ta_list_lol_exist(ta_number, pp_set_handle, &pp_set))
03010                 rsbac_ta_list_lol_remove(ta_number, pp_set_handle, &pp_set);
03011               return rsbac_ta_list_remove(ta_number, tkt_handle, &tid.tkt);
03012             }
03013 
03014           default:
03015             return(-RSBAC_EINVALIDTARGET);          
03016         }
03017     };      /* end of rsbac_remove_target() */
03018 
03019 /* end of pm_data_structures.c */

Generated on Fri Jun 17 09:45:25 2005 for RSBAC by  doxygen 1.4.2