On 08/14/2013 10:51 PM, Richard Maciel wrote:
> tools subdir is not useful anymore and got a GPL license
>
> Signed-off-by: Richard Maciel <[email protected]>

Acked-by: Joel Schopp <[email protected]>


> ---
>   configure.in       |   1 -
>   tools/Makefile.am  |   9 --
>   tools/ps_convert.c | 261 ---------------------------------------
>   tools/ps_inspect.c | 349 
> -----------------------------------------------------
>   4 files changed, 620 deletions(-)
>   delete mode 100644 tools/Makefile.am
>   delete mode 100644 tools/ps_convert.c
>   delete mode 100644 tools/ps_inspect.c
>
> diff --git a/configure.in b/configure.in
> index 0019503..2d9805c 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -387,7 +387,6 @@ AC_OUTPUT(dist/tcsd.conf \
>         src/tspi/Makefile \
>         src/trspi/Makefile \
>         src/tcsd/Makefile \
> -       tools/Makefile \
>         man/man8/tcsd.8 \
>         man/man5/tcsd.conf.5 \
>         dist/Makefile \
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> deleted file mode 100644
> index 41c87ba..0000000
> --- a/tools/Makefile.am
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -noinst_PROGRAMS=ps_inspect ps_convert
> -
> -ps_inspect_SOURCES=ps_inspect.c
> -ps_inspect_LDADD=${top_builddir}/src/tspi/libtspi.la
> -ps_inspect_CFLAGS=-I${top_srcdir}/src/include
> -
> -ps_convert_SOURCES=ps_convert.c
> -ps_convert_LDADD=${top_builddir}/src/tspi/libtspi.la
> -ps_convert_CFLAGS=-I${top_srcdir}/src/include
> diff --git a/tools/ps_convert.c b/tools/ps_convert.c
> deleted file mode 100644
> index 2a2d85a..0000000
> --- a/tools/ps_convert.c
> +++ /dev/null
> @@ -1,261 +0,0 @@
> -/*
> - *
> - *   Copyright (C) International Business Machines  Corp., 2005
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program is distributed in the hope that it will be useful,
> - *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
> - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> - *   the GNU General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> - */
> -
> -/*
> - * ps_convert.c
> - *
> - *   Convert a persistent storage file from one version to another.
> - *
> - *   There are 2 different types of persistent storage files:
> - *
> - * A)
> - *
> - * [UINT32   num_keys_on_disk]
> - * [TSS_UUID uuid0           ]
> - * [TSS_UUID uuid_parent0    ]
> - * [UINT16   pub_data_size0  ]
> - * [UINT16   blob_size0      ]
> - * [UINT16   cache_flags0    ]
> - * [BYTE[]   pub_data0       ]
> - * [BYTE[]   blob0           ]
> - * [...]
> - *
> - * B)
> - *
> - * [BYTE     TrouSerS PS version='1']
> - * [UINT32   num_keys_on_disk       ]
> - * [TSS_UUID uuid0                  ]
> - * [TSS_UUID uuid_parent0           ]
> - * [UINT16   pub_data_size0         ]
> - * [UINT16   blob_size0             ]
> - * [UINT32   vendor_data_size0      ]
> - * [UINT16   cache_flags0           ]
> - * [BYTE[]   pub_data0              ]
> - * [BYTE[]   blob0                  ]
> - * [BYTE[]   vendor_data0           ]
> - * [...]
> - *
> - */
> -
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <errno.h>
> -#include <string.h>
> -
> -#include <trousers/tss.h>
> -
> -#define PRINTERR(...)        fprintf(stderr, ##__VA_ARGS__)
> -#define PRINT(...)   printf("PS " __VA_ARGS__)
> -
> -#define OUT(stream, buf, size) \
> -     do { \
> -             if (fwrite(buf, size, 1, stream) != 1) { \
> -                     PRINTERR("fwrite error: %s\n", strerror(errno)); \
> -                     return -1; \
> -             } \
> -     } while (0)
> -
> -/* one global buffer we read into from the PS file */
> -unsigned char buf[1024];
> -
> -void
> -usage(char *argv0)
> -{
> -     PRINTERR("usage: %s filename\n"
> -              "\nBrings a persistent storage file up to date with the latest 
> "
> -              "version of trousers.\nOutput will be to \"filename.new\".\n", 
> argv0);
> -     exit(-1);
> -}
> -
> -void
> -print_hex(BYTE *buf, UINT32 len)
> -{
> -     UINT32 i = 0, j;
> -
> -     while (i < len) {
> -             for (j=0; (j < 4) && (i < len); j++, i+=4)
> -                     printf("%02x%02x%02x%02x ",
> -                             buf[i] & 0xff, buf[i+1] & 0xff,
> -                             buf[i+2] & 0xff, buf[i+3] & 0xff);
> -             printf("\n");
> -     }
> -}
> -
> -
> -int
> -convertkey_0(FILE *in, FILE *out)
> -{
> -     UINT16 pub_data_size, blob_size, cache_flags;
> -     UINT32 vendor_data_size = 0;
> -     int members;
> -
> -     /* output the key's UUID and parent UUID */
> -     OUT(out, buf, sizeof(TSS_UUID));
> -     OUT(out, &buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
> -
> -     pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
> -     blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
> -     cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + 2*sizeof(UINT16)];
> -
> -     OUT(out, &pub_data_size, sizeof(UINT16));
> -     OUT(out, &blob_size, sizeof(UINT16));
> -     OUT(out, &vendor_data_size, sizeof(UINT32));
> -     OUT(out, &cache_flags, sizeof(UINT16));
> -
> -     /* trash buf, we've got what we needed from it */
> -     if ((members = fread(buf, pub_data_size + blob_size,
> -                     1, in)) != 1) {
> -             PRINTERR("fread: %s: %d members read\n", strerror(errno), 
> members);
> -             return -1;
> -     }
> -
> -     OUT(out, buf, pub_data_size);
> -     OUT(out, &buf[pub_data_size], blob_size);
> -
> -     return 0;
> -}
> -
> -int
> -version_0_convert(FILE *in, FILE *out)
> -{
> -     int rc, members = 0;
> -     UINT32 i;
> -     UINT32 *u32 = (UINT32 *) &buf;
> -
> -     /* output the PS version */
> -     OUT(out, "\1", 1);
> -
> -     /* number of keys */
> -     OUT(out, u32, sizeof(UINT32));
> -
> -     /* The +- 1's below account for the byte we read in to determine
> -      * if the PS file had a version byte at the beginning */
> -
> -     /* align the beginning of the buffer with the beginning of the key */
> -     memcpy(buf, &buf[4], sizeof(TSS_UUID) + 1);
> -
> -     /* read in the rest of the first key's header */
> -     if ((members = fread(&buf[sizeof(TSS_UUID) + 1],
> -                     sizeof(TSS_UUID) + (3 * sizeof(UINT16)) - 1,
> -                     1, in)) != 1) {
> -             PRINTERR("fread: %s\n", strerror(errno));
> -             return -1;
> -     }
> -
> -     if (convertkey_0(in, out)) {
> -             PRINTERR("printkey_0 failed.\n");
> -             return -1;
> -     }
> -
> -     for (i = 1; i < *u32; i++) {
> -             /* read in subsequent key's headers */
> -             if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16),
> -                                     1, in)) != 1) {
> -                     PRINTERR("fread: %s\n", strerror(errno));
> -                     return -1;
> -             }
> -
> -             if ((rc = convertkey_0(in, out)))
> -                     return rc;
> -     }
> -
> -     return 0;
> -}
> -
> -int
> -inspect(char *filename, FILE *in)
> -{
> -     int members = 0, rc, namelen;
> -     FILE *out = NULL;
> -     char outfile[256];
> -     UINT32 *num_keys;
> -     TSS_UUID SRK_UUID = TSS_UUID_SRK;
> -
> -     /* do the initial read, which should include sizeof(TSS_UUID)
> -      * + sizeof(UINT32) + 1 bytes */
> -     if ((members = fread(buf,
> -                     sizeof(TSS_UUID) + sizeof(UINT32) + 1,
> -                     1, in)) != 1) {
> -             PRINTERR("fread: %s\n", strerror(errno));
> -             return -1;
> -     }
> -
> -     if (buf[0] == '\1') {
> -             num_keys = (UINT32 *)&buf[1];
> -             if (*num_keys == 0)
> -                     goto version0;
> -
> -             if (memcmp(&buf[5], &SRK_UUID, sizeof(TSS_UUID)))
> -                     goto version0;
> -
> -             printf("%s is already up to date.\n", filename);
> -
> -             return -2;
> -     }
> -
> -version0:
> -     if (memcmp(&buf[4], &SRK_UUID, sizeof(TSS_UUID))) {
> -             printf("This file does not appear to be a valid PS file.\n");
> -             return -2;
> -     }
> -
> -     printf("%s appears to be a version 0 PS file. Updating to version 1... 
> ",
> -                     filename);
> -
> -     namelen = strlen(filename);
> -     memcpy(outfile, filename, namelen);
> -     memcpy(&outfile[namelen], ".new", 5);
> -
> -     if ((out = fopen(outfile, "w+")) == NULL) {
> -             PRINTERR("fopen(%s, \"w+\"): %s\n", outfile, strerror(errno));
> -             return -1;
> -     }
> -
> -     rc = version_0_convert(in, out);
> -
> -     fclose(out);
> -
> -     return rc;
> -}
> -
> -int
> -main(int argc, char ** argv)
> -{
> -     FILE *in = NULL;
> -     int rc;
> -
> -     if (argc != 2)
> -             usage(argv[0]);
> -
> -     if ((in = fopen(argv[1], "r")) == NULL) {
> -             PRINTERR("fopen(%s, \"r\"): %s\n", argv[1], strerror(errno));
> -             return -1;
> -     }
> -
> -     if ((rc = inspect(argv[1], in)) == 0) {
> -             printf("Success.\n");
> -     } else if (rc != -2) {
> -             printf("Failure.\n");
> -     }
> -
> -     fclose(in);
> -
> -     return rc;
> -}
> diff --git a/tools/ps_inspect.c b/tools/ps_inspect.c
> deleted file mode 100644
> index 3c2437c..0000000
> --- a/tools/ps_inspect.c
> +++ /dev/null
> @@ -1,349 +0,0 @@
> -/*
> - *
> - *   Copyright (C) International Business Machines  Corp., 2005
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program is distributed in the hope that it will be useful,
> - *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
> - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> - *   the GNU General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> - */
> -
> -/*
> - * ps_inspect.c
> - *
> - *   Inspect a persistent storage file, printing information about it based
> - *   on best guesses.
> - *
> - *   There are 2 different types of persistent storage files:
> - *
> - * A)
> - *
> - * [UINT32   num_keys_on_disk]
> - * [TSS_UUID uuid0           ]
> - * [TSS_UUID uuid_parent0    ]
> - * [UINT16   pub_data_size0  ]
> - * [UINT16   blob_size0      ]
> - * [UINT16   cache_flags0    ]
> - * [BYTE[]   pub_data0       ]
> - * [BYTE[]   blob0           ]
> - * [...]
> - *
> - * B)
> - *
> - * [BYTE     TrouSerS PS version='1']
> - * [UINT32   num_keys_on_disk       ]
> - * [TSS_UUID uuid0                  ]
> - * [TSS_UUID uuid_parent0           ]
> - * [UINT16   pub_data_size0         ]
> - * [UINT16   blob_size0             ]
> - * [UINT32   vendor_data_size0      ]
> - * [UINT16   cache_flags0           ]
> - * [BYTE[]   pub_data0              ]
> - * [BYTE[]   blob0                  ]
> - * [BYTE[]   vendor_data0           ]
> - * [...]
> - *
> - */
> -
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <errno.h>
> -#include <string.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <sys/unistd.h>
> -
> -#include <trousers/tss.h>
> -
> -#define PRINTERR(...)        fprintf(stderr, ##__VA_ARGS__)
> -#define PRINT(...)   printf("PS " __VA_ARGS__)
> -
> -#if (defined (__FreeBSD__) || defined (__OpenBSD__))
> -#define OFF_T_PRINTF "lld"
> -#else
> -#define OFF_T_PRINTF "ld"
> -#endif
> -
> -/* one global buffer we read into from the PS file */
> -unsigned char buf[1024];
> -
> -void
> -usage(char *argv0)
> -{
> -     PRINTERR("usage: %s filename\n", argv0);
> -     exit(-1);
> -}
> -
> -void
> -print_hex(BYTE *buf, UINT32 len)
> -{
> -     UINT32 i, j;
> -
> -     for (i=0, j=1; (i+4) < len; j++, i+=4) {
> -             printf("%02x%02x%02x%02x ",
> -                     buf[i] & 0xff, buf[i+1] & 0xff,
> -                     buf[i+2] & 0xff, buf[i+3] & 0xff);
> -             if (!(j % 4))
> -                     printf("\n");
> -     }
> -
> -     while (i < len)
> -             printf("%02x", buf[i++] & 0xff);
> -     printf("\n");
> -}
> -
> -int
> -printkey_0(int i, FILE *f)
> -{
> -     UINT16 pub_data_size, blob_size, cache_flags;
> -     int members;
> -
> -     PRINT("uuid%d: ", i);
> -     print_hex(buf, sizeof(TSS_UUID));
> -
> -     PRINT("parent uuid%d: ", i);
> -     print_hex(&buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
> -
> -     pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
> -     blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
> -     cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + 2*sizeof(UINT16)];
> -
> -     PRINT("pub_data_size%d: %hu\n", i, pub_data_size);
> -     PRINT("blob_size%d: %hu\n", i, blob_size);
> -     PRINT("cache_flags%d: %02hx\n", i, cache_flags);
> -
> -     /* trash buf, we've got what we needed from it */
> -     if ((members = fread(buf, pub_data_size + blob_size,
> -                     1, f)) != 1) {
> -             PRINTERR("fread: %s: %d members read\n", strerror(errno), 
> members);
> -             return -1;
> -     }
> -
> -     PRINT("pub_data%d:\n", i);
> -     print_hex(buf, pub_data_size);
> -
> -     PRINT("blob%d:\n", i);
> -     print_hex(&buf[pub_data_size], blob_size);
> -
> -     return 0;
> -}
> -
> -int
> -printkey_1(int i, FILE *f)
> -{
> -     UINT16 pub_data_size, blob_size, cache_flags;
> -     UINT32 vendor_data_size;
> -     int members;
> -
> -     PRINT("uuid%d: ", i);
> -     print_hex(buf, sizeof(TSS_UUID));
> -
> -     PRINT("parent uuid%d: ", i);
> -     print_hex(&buf[sizeof(TSS_UUID)], sizeof(TSS_UUID));
> -
> -     pub_data_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID))];
> -     blob_size = *(UINT16 *)&buf[(2 * sizeof(TSS_UUID)) + sizeof(UINT16)];
> -     vendor_data_size = *(UINT32 *)&buf[(2 * sizeof(TSS_UUID)) + 
> 2*sizeof(UINT16)];
> -     cache_flags = *(UINT16 *)&buf[2*sizeof(TSS_UUID) + sizeof(UINT16) + 
> sizeof(UINT32)];
> -
> -     PRINT("pub_data_size%d: %hu\n", i, pub_data_size);
> -     PRINT("blob_size%d: %hu\n", i, blob_size);
> -     PRINT("vendor_data_size%d: %u\n", i, vendor_data_size);
> -     PRINT("cache_flags%d: %02hx\n", i, cache_flags);
> -
> -     /* trash buf, we've got what we needed from it */
> -     if ((members = fread(buf, pub_data_size + blob_size + vendor_data_size,
> -                     1, f)) != 1) {
> -             PRINTERR("fread: %s: %d members read\n", strerror(errno), 
> members);
> -             return -1;
> -     }
> -
> -     PRINT("pub_data%d:\n", i);
> -     print_hex(buf, pub_data_size);
> -
> -     PRINT("blob%d:\n", i);
> -     print_hex(&buf[pub_data_size], blob_size);
> -
> -     PRINT("vendor_data%d:\n", i);
> -     if (vendor_data_size > 0)
> -             print_hex(&buf[pub_data_size + blob_size], vendor_data_size);
> -
> -     return 0;
> -}
> -
> -int
> -version_0_print(FILE *f)
> -{
> -     int rc, members = 0;
> -     UINT32 i;
> -     UINT32 *u32 = (UINT32 *) &buf;
> -
> -     PRINT("version:        0\n");
> -     PRINT("number of keys: %u\n", *u32);
> -
> -     /* The +- 1's below account for the byte we read in to determine
> -      * if the PS file had a version byte at the beginning */
> -
> -     /* align the beginning of the buffer with the beginning of the key */
> -     memcpy(buf, &buf[4], sizeof(TSS_UUID) + 1);
> -
> -     /* read in the rest of the first key's header */
> -     if ((members = fread(&buf[sizeof(TSS_UUID) + 1],
> -                     sizeof(TSS_UUID) + (3 * sizeof(UINT16)) - 1,
> -                     1, f)) != 1) {
> -             PRINTERR("fread: %s\n", strerror(errno));
> -             return -1;
> -     }
> -
> -     if (printkey_0(0, f)) {
> -             PRINTERR("printkey_0 failed.\n");
> -             return -1;
> -     }
> -
> -     for (i = 1; i < *u32; i++) {
> -             /* read in subsequent key's headers */
> -             if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16),
> -                                     1, f)) != 1) {
> -                     PRINTERR("fread: %s\n", strerror(errno));
> -                     return -1;
> -             }
> -
> -             if ((rc = printkey_0(i, f)))
> -                     return rc;
> -     }
> -
> -     return 0;
> -}
> -
> -int
> -version_1_print(FILE *f)
> -{
> -     int rc, members = 0;
> -     UINT32 i, u32 = *(UINT32 *)&buf[1];
> -
> -     PRINT("version:        1\n");
> -     PRINT("number of keys: %u\n", u32);
> -
> -     /* align the beginning of the buffer with the beginning of the key */
> -     memcpy(buf, &buf[5], sizeof(TSS_UUID));
> -
> -     /* read in the rest of the first key's header */
> -     if ((members = fread(&buf[sizeof(TSS_UUID)],
> -                     sizeof(TSS_UUID) + (3 * sizeof(UINT16)) + 
> sizeof(UINT32),
> -                     1, f)) != 1) {
> -             PRINTERR("fread: %s\n", strerror(errno));
> -             return -1;
> -     }
> -
> -     if (printkey_1(0, f)) {
> -             PRINTERR("printkey_1 failed.\n");
> -             return -1;
> -     }
> -
> -     for (i = 1; i < u32; i++) {
> -             /* read in subsequent key's headers */
> -             if ((members = fread(buf, 2*sizeof(TSS_UUID) + 3*sizeof(UINT16)
> -                                     + sizeof(UINT32), 1, f)) != 1) {
> -                     PRINTERR("fread: %s\n", strerror(errno));
> -                     return -1;
> -             }
> -
> -             if ((rc = printkey_1(i, f)))
> -                     return rc;
> -     }
> -
> -     return 0;
> -}
> -
> -/* the smallest key on disk should be around 360 bytes total
> - * and the largest should be about 560 bytes, so if the number
> - * of keys is not in this ballpark, this is probably not a PS
> - * file
> - */
> -int
> -bad_file_size(UINT32 num_keys, off_t file_size)
> -{
> -     if ((num_keys * 360) > (unsigned long)file_size)
> -             return 1;
> -
> -     if ((num_keys * 560) < (unsigned long)file_size)
> -             return 1;
> -
> -     return 0;
> -}
> -
> -int
> -inspect(FILE *f, off_t file_size)
> -{
> -     int members = 0;
> -     UINT32 *num_keys;
> -
> -     /* do the initial read, which should include sizeof(TSS_UUID)
> -      * + sizeof(UINT32) + 1 bytes */
> -     if ((members = fread(buf,
> -                     sizeof(TSS_UUID) + sizeof(UINT32) + 1,
> -                     1, f)) != 1) {
> -             printf("File is empty.\n");
> -             return -1;
> -     }
> -
> -     if (buf[0] == '\1') {
> -             num_keys = (UINT32 *)&buf[1];
> -             if (*num_keys == 0 || bad_file_size(*num_keys, file_size))
> -                     goto version0;
> -
> -             return version_1_print(f);
> -     }
> -
> -version0:
> -     num_keys = (UINT32 *)&buf[0];
> -     if (*num_keys == 0 || bad_file_size(*num_keys, file_size)) {
> -             printf("This file does not appear to be a valid PS file.\n");
> -             return -1;
> -     }
> -
> -     return version_0_print(f);
> -}
> -
> -int
> -main(int argc, char ** argv)
> -{
> -     FILE *f = NULL;
> -     int rc;
> -     struct stat stat_buf;
> -     off_t file_size;
> -
> -     if (argc != 2)
> -             usage(argv[0]);
> -
> -     if ((f = fopen(argv[1], "r")) == NULL) {
> -             PRINTERR("fopen(%s): %s\n", argv[1], strerror(errno));
> -             return -1;
> -     }
> -
> -     if ((rc = fstat(fileno(f), &stat_buf))) {
> -             PRINTERR("fstat(%s): %s\n", argv[1], strerror(errno));
> -             fclose(f);
> -             return -1;
> -     }
> -
> -     file_size = stat_buf.st_size;
> -
> -     PRINT("filename: %s (%lld bytes)\n", argv[1], (long long) file_size);
> -
> -     rc = inspect(f, file_size);
> -
> -     fclose(f);
> -
> -     return rc;
> -}
>


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to