settings.h 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _SETTINGS_H
  2. #define _SETTINGS_H
  3. // If changing this, need to also change the usage in main.c which assumes all of it is \200
  4. #define SETTINGS_HEADER "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"
  5. #define PREFIXLEN sizeof(SETTINGS_HEADER)
  6. /* !!! THIS MUST BE CHANGED WHEN CHANGING THE PACK STRUCT OR ALGORITHMS !!! */
  7. #define SETTINGS_VER 3
  8. #define DYNAMIC_HEADER dynamic_initialized
  9. typedef struct settings_struct {
  10. char prefix[PREFIXLEN];
  11. /* -- STATIC -- */
  12. // char hash[33];
  13. char hash[49];
  14. char packname[65];
  15. char shellhash[65];
  16. char owners[513];
  17. char hubs[513];
  18. char salt1[33];
  19. char salt2[17];
  20. char dcc_prefix[17];
  21. char features[17];
  22. /* -- DYNAMIC -- */
  23. char dynamic_initialized[17];
  24. char conf_hubs[513];
  25. char bots[1025];
  26. char uid[17];
  27. char autocron[17]; /* should the bot auto crontab itself? */
  28. char username[49]; /* shell username */
  29. char datadir[1025];
  30. char homedir[1025]; /* homedir */
  31. char portmin[17]; /* for hubs, the reserved port range for incoming connections */
  32. char portmax[17]; /* for hubs, the reserved port range for incoming connections */
  33. /* -- PADDING -- */
  34. char padding[13]; // (16 - (sizeof(settings_t) % 16)) % 16]
  35. } settings_t;
  36. #define SALT1 {s1_1[0],s1_1[1],s1_5[0],s1_5[1],s1_8[0],s1_8[1],s1_4[0],s1_9[1],s1_2[0],s1_13[0],s1_6[0],s1_6[1],s1_7[0],s1_7[1],s1_3[0],s1_13[1],s1_16[1],s1_4[1],s1_15[0],s1_10[1],s1_14[0],s1_14[1],s1_12[0],s1_12[1],s1_2[1],s1_3[1],s1_11[0],s1_11[1],s1_10[0],s1_15[1],s1_16[0],s1_9[0],'\0'}
  37. #define SALT2 {s2_5[0],s2_5[1],s2_2[0],s2_2[1],s2_8[1],s2_4[0],s2_7[1],s2_4[1],s2_1[0],s2_6[0],s2_1[1],s2_6[1],s2_3[0],s2_3[1],s2_8[0],s2_7[0],'\0'}
  38. #define _x_1 settings.salt1
  39. #define _x_2 settings.salt2
  40. #define INIT_SALTS s2_6[1]=_x_2[11];s1_10[0]=_x_1[28];s1_5[1]=_x_1[3];s2_4[0]=_x_2[5];s1_2[1]=_x_1[24];s2_2[1]=_x_2[3];s1_13[1]=_x_1[15];s1_7[0]=_x_1[12];s1_4[1]=_x_1[17];s2_8[0]=_x_2[14];s1_6[0]=_x_1[10];s1_15[0]=_x_1[18];s1_7[1]=_x_1[13];s1_8[0]=_x_1[4];s1_16[0]=_x_1[30];s1_1[0]=_x_1[0];s1_9[1]=_x_1[7];s1_3[1]=_x_1[25];s2_3[1]=_x_2[13];s2_4[1]=_x_2[7];s1_3[0]=_x_1[14];s1_12[0]=_x_1[22];s1_8[1]=_x_1[5];s1_1[1]=_x_1[1];s2_1[0]=_x_2[8];s1_10[1]=_x_1[19];s1_14[0]=_x_1[20];s1_11[0]=_x_1[26];s2_7[1]=_x_2[6];s2_1[1]=_x_2[10];s1_9[0]=_x_1[31];s2_2[0]=_x_2[2];s1_15[1]=_x_1[29];s2_5[1]=_x_2[1];s2_5[0]=_x_2[0];s1_16[1]=_x_1[16];s2_6[0]=_x_2[9];s1_13[0]=_x_1[9];s1_2[0]=_x_1[8];s1_5[0]=_x_1[2];s2_8[1]=_x_2[4];s1_6[1]=_x_1[11];s2_3[0]=_x_2[12];s2_7[0]=_x_2[15];s1_12[1]=_x_1[23];s1_4[0]=_x_1[6];s1_14[1]=_x_1[21];s1_11[1]=_x_1[27];
  41. #define CLEAR_SALTS s2_6[1]=rand();s1_10[0]=rand();s1_5[1]=rand();s2_4[0]=rand();s1_2[1]=rand();s2_2[1]=rand();s1_13[1]=rand();s1_7[0]=rand();s1_4[1]=rand();s2_8[0]=rand();s1_6[0]=rand();s1_15[0]=rand();s1_7[1]=rand();s1_8[0]=rand();s1_16[0]=rand();s1_1[0]=rand();s1_9[1]=rand();s1_3[1]=rand();s2_3[1]=rand();s2_4[1]=rand();s1_3[0]=rand();s1_12[0]=rand();s1_8[1]=rand();s1_1[1]=rand();s2_1[0]=rand();s1_10[1]=rand();s1_14[0]=rand();s1_11[0]=rand();s2_7[1]=rand();s2_1[1]=rand();s1_9[0]=rand();s2_2[0]=rand();s1_15[1]=rand();s2_5[1]=rand();s2_5[0]=rand();s1_16[1]=rand();s2_6[0]=rand();s1_13[0]=rand();s1_2[0]=rand();s1_5[0]=rand();s2_8[1]=rand();s1_6[1]=rand();s2_3[0]=rand();s2_7[0]=rand();s1_12[1]=rand();s1_4[0]=rand();s1_14[1]=rand();s1_11[1]=rand();OPENSSL_cleanse(s1_1,sizeof(s1_1));OPENSSL_cleanse(s1_3,sizeof(s1_3));OPENSSL_cleanse(s1_7,sizeof(s1_7));OPENSSL_cleanse(s2_1,sizeof(s2_1));OPENSSL_cleanse(s2_3,sizeof(s2_3));OPENSSL_cleanse(s2_7,sizeof(s2_7));
  42. extern char s1_3[3],s1_2[3],s1_1[3],s2_7[3],s1_9[3],s1_13[3],s1_14[3],s2_2[3],s1_10[3],s2_4[3],s1_4[3],s2_3[3],s2_1[3],s2_6[3],s1_7[3],s1_12[3],s2_5[3],s1_5[3],s1_6[3],s1_11[3],s2_8[3],s1_8[3],s1_16[3],s1_15[3];
  43. #define SIZE_PACK sizeof(settings.hash) + sizeof(settings.packname) + sizeof(settings.shellhash) + \
  44. sizeof(settings.owners) + sizeof(settings.hubs) + \
  45. sizeof(settings.salt1) + sizeof(settings.salt2) + sizeof(settings.dcc_prefix) + sizeof(settings.features)
  46. #define SIZE_CONF sizeof(settings.dynamic_initialized) + sizeof(settings.conf_hubs) + sizeof(settings.bots) + sizeof(settings.uid) + \
  47. sizeof(settings.autocron) + \
  48. sizeof(settings.username) + sizeof(settings.homedir) + \
  49. sizeof(settings.portmin) + sizeof(settings.portmin) + sizeof(settings.datadir)
  50. #define SIZE_PAD sizeof(settings.padding)
  51. #define SIZE_SETTINGS sizeof(settings_t)
  52. extern settings_t settings;
  53. #endif /* !_SETTINGS_H */