Hello, The attached patches address ticket https://fedorahosted.org/sssd/ticket/2106 The patches do not define new flags as suggested in the ticket. As we discussed with Nalin we try to detect the encoding based on the BOM and do the right thing without flags. If we see that this is not enough we will add flags but that would add a new function so such change would be destined for a bigger release. For now I think the use case is addressed. If we see the need to other use cases we will open other tickets.
The patch depends on the previous set of patches that deal with C-Style comments. I also found some other unrelated issue that I logged as a separate ticket. https://fedorahosted.org/sssd/ticket/2119 -- Thank you, Dmitri Pal Sr. Engineering Manager for IdM portfolio Red Hat Inc. ------------------------------- Looking to carve out IT costs? www.redhat.com/carveoutcosts/
From ee1988301ba164a12263b7faf8c9bf686174deab Mon Sep 17 00:00:00 2001 From: Dmitri Pal <d...@redhat.com> Date: Thu, 10 Oct 2013 22:47:23 -0400 Subject: [PATCH 3/4] [INI] Convert files to UTF Patch adds functionality that detects BOM at the beginning of the file and uses it to convert to UTF8. If no BOM is detected file is assumed to be UTF8 encoded. --- ini/ini_fileobj.c | 317 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 306 insertions(+), 11 deletions(-) diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c index 7ac9dc6..000d36e 100644 --- a/ini/ini_fileobj.c +++ b/ini/ini_fileobj.c @@ -21,14 +21,29 @@ #include "config.h" #include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include <string.h> #include <stdlib.h> +#include <iconv.h> #include "trace.h" #include "ini_defines.h" #include "ini_configobj.h" #include "ini_config_priv.h" #include "path_utils.h" +#define ICONV_BUFFER 100 + +#define BOM4_SIZE 4 +#define BOM3_SIZE 3 +#define BOM2_SIZE 2 + +#define INDEX_UTF32BE 0 +#define INDEX_UTF32LE 1 +#define INDEX_UTF16BE 2 +#define INDEX_UTF16LE 3 +#define INDEX_UTF8 4 /* Close file but not destroy the object */ void ini_config_file_close(struct ini_cfgfile *file_ctx) @@ -52,6 +67,7 @@ void ini_config_file_destroy(struct ini_cfgfile *file_ctx) if(file_ctx) { free(file_ctx->filename); + simplebuffer_free(file_ctx->file_data); if(file_ctx->file) fclose(file_ctx->file); free(file_ctx); } @@ -59,37 +75,298 @@ void ini_config_file_destroy(struct ini_cfgfile *file_ctx) TRACE_FLOW_EXIT(); } -/* Internal common initialization part */ -static int common_file_init(struct ini_cfgfile *file_ctx) +/* How much I plan to read? */ +size_t how_much_to_read(size_t left, size_t increment) +{ + if(left > increment) return increment; + else return left; +} + +int check_bom(int ind, unsigned char *buffer, size_t len, size_t *bom_shift) +{ + TRACE_FLOW_ENTRY(); + + if (len > BOM4_SIZE) { + if ((buffer[0] == 0x00) && + (buffer[1] == 0x00) && + (buffer[2] == 0xFE) && + (buffer[3] == 0xFF)) { + TRACE_FLOW_RETURN(INDEX_UTF32BE); + *bom_shift = BOM4_SIZE; + return INDEX_UTF32BE; + } + else if ((buffer[0] == 0xFF) && + (buffer[1] == 0xFE) && + (buffer[2] == 0x00) && + (buffer[3] == 0x00)) { + TRACE_FLOW_RETURN(INDEX_UTF32LE); + *bom_shift = BOM4_SIZE; + return INDEX_UTF32LE; + } + } + + if (len > BOM3_SIZE) { + if ((buffer[0] == 0xEF) && + (buffer[1] == 0xBB) && + (buffer[2] == 0xBF)) { + TRACE_FLOW_RETURN(INDEX_UTF8); + *bom_shift = BOM3_SIZE; + return INDEX_UTF8; + } + } + + if (len > BOM2_SIZE) { + if ((buffer[0] == 0xFE) && + (buffer[1] == 0xFF)) { + TRACE_FLOW_RETURN(INDEX_UTF16BE); + *bom_shift = BOM2_SIZE; + return INDEX_UTF16BE; + } + else if ((buffer[0] == 0xFF) && + (buffer[1] == 0xFE)) { + TRACE_FLOW_RETURN(INDEX_UTF16LE); + *bom_shift = BOM2_SIZE; + return INDEX_UTF16LE; + } + } + + TRACE_FLOW_RETURN(ind); + return ind; +} + +/* Internal conversion part */ +static int common_file_convert(int raw_file, struct ini_cfgfile *file_ctx) { int error = EOK; + size_t read_cnt = 0; + size_t total_read = 0; + size_t to_read = 0; + size_t in_buffer = 0; + int ind = INDEX_UTF8; + iconv_t conv = 0; + size_t conv_res = 0; + char read_buf[ICONV_BUFFER+1]; + char result_buf[ICONV_BUFFER]; + char *src, *dest; + size_t to_convert = 0; + size_t room_left = 0; + size_t bom_shift = 0; + const char *encodings[] = { "UTF-32BE", + "UTF-32LE", + "UTF-16BE", + "UTF-16LE", + "UTF-8" }; TRACE_FLOW_ENTRY(); + do { + to_read = how_much_to_read(file_ctx->file_stats.st_size - total_read, + ICONV_BUFFER - in_buffer); + + TRACE_INFO_NUMBER("About to read", to_read); + errno = 0; + read_cnt = read(raw_file, read_buf + in_buffer, to_read); + if (read_cnt == -1) { + error = errno; + close(raw_file); + TRACE_ERROR_NUMBER("Failed to read data from file", error); + return error; + } + + if (read_cnt != to_read) { + error = EIO; + close(raw_file); + TRACE_ERROR_NUMBER("Read less than required", error); + return error; + } + + /* First time do some initialization */ + if(total_read == 0) { + TRACE_INFO_STRING("Reading first time.","Checking BOM"); + + ind = check_bom(ind, (unsigned char *)read_buf, read_cnt, &bom_shift); + + TRACE_INFO_STRING("Converting to", encodings[INDEX_UTF8]); + TRACE_INFO_STRING("Converting from", encodings[ind]); + + errno = 0; + conv = iconv_open(encodings[INDEX_UTF8], encodings[ind]); + if (conv == (iconv_t) -1) { + error = errno; + close(raw_file); + TRACE_ERROR_NUMBER("Failed to create converter", error); + return error; + } + } + total_read += read_cnt; + TRACE_INFO_NUMBER("Total read", total_read); + + do { + /* Do conversion */ + errno = 0; + src = read_buf + bom_shift; + dest = result_buf; + to_convert = read_cnt + in_buffer - bom_shift; + bom_shift = 0; + room_left = ICONV_BUFFER; + conv_res = iconv(conv, &src, &to_convert, &dest, &room_left); + if (conv == (iconv_t) -1) { + error = errno; + switch(error) { + case EILSEQ: + TRACE_ERROR_NUMBER("Invalid multibyte encoding", error); + close(raw_file); + iconv_close(conv); + return error; + case EINVAL: + /* We need to just read more if we can */ + if (total_read != file_ctx->file_stats.st_size) { + TRACE_INFO_STRING("Incomplete sequence.", ""); + TRACE_INFO_NUMBER("File size.", + file_ctx->file_stats.st_size); + memmove(read_buf, src, to_convert); + in_buffer = to_convert; + } + else { + /* Or return error if we can't */ + TRACE_ERROR_NUMBER("Incomplete sequence", error); + close(raw_file); + iconv_close(conv); + return error; + } + case E2BIG: + TRACE_INFO_STRING("No room in the output buffer.", ""); + error = simplebuffer_add_raw(file_ctx->file_data, + result_buf, + ICONV_BUFFER - room_left, + ICONV_BUFFER); + if (error) { + TRACE_ERROR_NUMBER("Failed to store converted bytes", + error); + close(raw_file); + iconv_close(conv); + return error; + } + + room_left = ICONV_BUFFER; + dest = result_buf; + continue; + default: + TRACE_ERROR_NUMBER("Unexpected internal error", + error); + close(raw_file); + iconv_close(conv); + return ENOTSUP; + } + } + /* The whole buffer was sucessfully converted */ + error = simplebuffer_add_raw(file_ctx->file_data, + result_buf, + ICONV_BUFFER - room_left, + ICONV_BUFFER); + if (error) { + TRACE_ERROR_NUMBER("Failed to store converted bytes", + error); + close(raw_file); + iconv_close(conv); + return error; + } + TRACE_INFO_STRING("Saved procesed portion.", + (char *)simplebuffer_get_vbuf(file_ctx->file_data)); + + in_buffer = 0; + break; + } + while (1); + } + while(total_read < file_ctx->file_stats.st_size); + + close(raw_file); + iconv_close(conv); + /* Open file */ - TRACE_INFO_STRING("File", file_ctx->filename); + TRACE_INFO_STRING("File data", + (char *)simplebuffer_get_vbuf(file_ctx->file_data)); + TRACE_INFO_NUMBER("File len", + simplebuffer_get_len(file_ctx->file_data)); + TRACE_INFO_NUMBER("Size", + file_ctx->file_data->size); errno = 0; - file_ctx->file = fopen(file_ctx->filename, "r"); + file_ctx->file = fmemopen(simplebuffer_get_vbuf(file_ctx->file_data), + simplebuffer_get_len(file_ctx->file_data), + "r"); if (!(file_ctx->file)) { error = errno; TRACE_ERROR_NUMBER("Failed to open file", error); return error; } - file_ctx->stats_read = 0; + TRACE_FLOW_EXIT(); + return EOK; +} + + +/* Internal common initialization part */ +static int common_file_init(struct ini_cfgfile *file_ctx) +{ + int error = EOK; + int raw_file = 0; + int stat_ret = 0; + + TRACE_FLOW_ENTRY(); + + TRACE_INFO_STRING("File", file_ctx->filename); + + /* Open file in binary mode first */ + errno = 0; + raw_file = open(file_ctx->filename, O_RDONLY); + if (raw_file == -1) { + error = errno; + TRACE_ERROR_NUMBER("Failed to open file in binary mode", error); + return error; + } + + /* Get the size of the file */ + errno = 0; + stat_ret = fstat(raw_file, &(file_ctx->file_stats)); + if (stat_ret == -1) { + error = errno; + TRACE_ERROR_NUMBER("Failed to get file stats", error); + return error; + } - /* Collect stats */ - if (file_ctx->metadata_flags & INI_META_STATS) { + /* Trick to overcome the fact that + * fopen and fmemopen behave differently when file + * is 0 length + */ + if (file_ctx->file_stats.st_size) { + error = common_file_convert(raw_file, file_ctx); + if (error) { + TRACE_ERROR_NUMBER("Failed to convert file", + error); + close(raw_file); + return error; + } + } + else { errno = 0; - if (fstat(fileno(file_ctx->file), - &(file_ctx->file_stats)) < 0) { + file_ctx->file = fdopen(raw_file, "r"); + if (!(file_ctx->file)) { error = errno; - TRACE_ERROR_NUMBER("Failed to get file stats.", error); + TRACE_ERROR_NUMBER("Failed to fdopen file", error); return error; } + + } + + /* Collect stats */ + if (file_ctx->metadata_flags & INI_META_STATS) { file_ctx->stats_read = 1; } - else memset(&(file_ctx->file_stats), 0, sizeof(struct stat)); + else { + memset(&(file_ctx->file_stats), 0, sizeof(struct stat)); + file_ctx->stats_read = 0; + } TRACE_FLOW_EXIT(); return EOK; @@ -119,6 +396,15 @@ int ini_config_file_open(const char *filename, new_ctx->filename = NULL; new_ctx->file = NULL; + new_ctx->file_data = NULL; + + error = simplebuffer_alloc(&(new_ctx->file_data)); + if (error) { + TRACE_ERROR_NUMBER("Failed to allocate buffer ctx.", error); + ini_config_file_destroy(new_ctx); + return error; + + } /* Store flags */ new_ctx->metadata_flags = metadata_flags; @@ -176,6 +462,15 @@ int ini_config_file_reopen(struct ini_cfgfile *file_ctx_in, } new_ctx->file = NULL; + new_ctx->file_data = NULL; + + error = simplebuffer_alloc(&(new_ctx->file_data)); + if (error) { + TRACE_ERROR_NUMBER("Failed to allocate buffer ctx.", error); + ini_config_file_destroy(new_ctx); + return error; + + } /* Store flags */ new_ctx->metadata_flags = file_ctx_in->metadata_flags; -- 1.7.1
From e4fcd1ba0f86675e6fe6455c80d5215b821af973 Mon Sep 17 00:00:00 2001 From: Dmitri Pal <d...@redhat.com> Date: Wed, 9 Oct 2013 23:29:22 -0400 Subject: [PATCH 1/4] [INI] Expose buffer context as void In some cases the intenal buffer needs to be accessed as void. Add a function that would do that instead of type casting and dealing with 'const'. --- basicobjects/simplebuffer.c | 7 +++++++ basicobjects/simplebuffer.h | 4 ++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/basicobjects/simplebuffer.c b/basicobjects/simplebuffer.c index 1e7b3fb..a86b518 100644 --- a/basicobjects/simplebuffer.c +++ b/basicobjects/simplebuffer.c @@ -208,6 +208,13 @@ const unsigned char *simplebuffer_get_buf(struct simplebuffer *data) return data->buffer; } +/* Get void buffer */ +void *simplebuffer_get_vbuf(struct simplebuffer *data) +{ + return (void *)data->buffer; +} + + /* Get length */ uint32_t simplebuffer_get_len(struct simplebuffer *data) { diff --git a/basicobjects/simplebuffer.h b/basicobjects/simplebuffer.h index 4d02321..3966932 100644 --- a/basicobjects/simplebuffer.h +++ b/basicobjects/simplebuffer.h @@ -74,6 +74,10 @@ int simplebuffer_write(int fd, /* Get buffer */ const unsigned char *simplebuffer_get_buf(struct simplebuffer *data); +/* Get buffer */ +void *simplebuffer_get_vbuf(struct simplebuffer *data); + + /* Get length */ uint32_t simplebuffer_get_len(struct simplebuffer *data); -- 1.7.1
From b48891b2753bd8d26f71f6cbb18b28bd22ece9cc Mon Sep 17 00:00:00 2001 From: Dmitri Pal <d...@redhat.com> Date: Thu, 10 Oct 2013 22:51:22 -0400 Subject: [PATCH 4/4] [INI] Updated unit test for UTF8 conversion Patch adds new test files and bom creation function. --- ini/ini.d/real16be.conf | Bin 0 -> 3288 bytes ini/ini.d/real16le.conf | Bin 0 -> 3288 bytes ini/ini.d/real32be.conf | Bin 0 -> 6576 bytes ini/ini.d/real32le.conf | Bin 0 -> 6576 bytes ini/ini.d/real8.conf | 70 +++++++++++++++++++++++++++++++++++++++++++++++ ini/ini_parse_ut.c | 35 +++++++++++++++++++++++ 6 files changed, 105 insertions(+), 0 deletions(-) create mode 100644 ini/ini.d/real16be.conf create mode 100644 ini/ini.d/real16le.conf create mode 100644 ini/ini.d/real32be.conf create mode 100644 ini/ini.d/real32le.conf create mode 100644 ini/ini.d/real8.conf diff --git a/ini/ini.d/real16be.conf b/ini/ini.d/real16be.conf new file mode 100644 index 0000000000000000000000000000000000000000..2e81831eda146b21752c73204b10da4449a51b6c GIT binary patch literal 3288 zcmc(hTW=FF5QXPCzry0B5^A#z1%!$aib@ekEmTb(kPwP;DQ%!hqijOyp9j7(j<dUI z(r|e|t4+N2%$f0-i~ZxLWjw*o?9v97Gm5_*MiV=?j$JYO%<L6k!EP8$kqyXR+tBBF zKGJx^T5dI-kEYp?YhKtVX1=jLVRhj1!Cru|Yjtb5d}a@MGS?isgzQ|SA>BT@IfxUq z$IO>8jw{l^4*XjlU)T(d&O*KhMwhvq-45LMYrdxVAzvDJQ%E$i*+*M;#fl_m>}O!# zZ66<mddY0YzB<Td@G}5CbNQVAG2dg?*I1rQa>`5wa`Z#?#L72TdyG!_AK`cMuk2YD z?Y^~HpW%Dg_2T*yR>ZkD4A!b3Do*EM7o3Spu`}Xdu?ntr<MHp!BU|<<`2G}o<-!&0 z-k{kha#2^=v+7X}RCkwejO7vNJ+~A6E|>|-7x}at*Uo&0%CYMHQ|$W0U>iS2_>}ud zF&z3xTzm#S=Iyf2iq?3e=dVDU@&;l!0ZS1T(-UUy%Si2N$kV}xKC;TQ%yYEJsdI8p zF-*DDFOAyn-8#?XZZ}oXJ2-1$_Y^BRdlk>W<9n)y78*VKigv1{->Zt~UCkr=ZyY3~ zRXL~XQ>4Yhzq1{&?(aw^*0kgQz-RJpH47=rH)X@yc{QjPsek=>{?<J|yWV4poNfDe zQD=S6{EpA2&Y)UIGw-RLl!dB_;I(>W@2RJz9r@SYzM~osc4!|w1}DfJ(y0#6I(Ch? z9`#y2d&uvZy+Q7DA(?Qa^fs9jyRSOEPLx}0M4u#?Fw_6t86l+eav7t%c1;Cc!ntfz zEeZQMC||rcOr05>I79r{XJy-0Z@mW9OA4guY3vYH&NJ9aY;MYm*c;-xpza@di)iVF zptCyo`H(vJ`i`x0NB4;f_Ssvo`P$>!A`&&$;yD+&(5V^svB#S7yKG&j?dphc+SMVQ zRlQ;C-YoAaodj{eUH9`X{k@4VHFTEyyfQ*Hqtm$16)VL`dA>ouskav%)aM;)y}t5L zy>^D3GS+&e`*|*7L_dqniF^5Ti|b;i`&H};%I;h4GKy=yI5oDof$0|Zh<DGn)=Eq7 zhJ1_uN~_7+<vnmM-BEOlYQt5viW=wy@SpSh7+KZSGnfoSqG3<Tqk!c{_7dC5uo<Z0 zZxxa>B3d1d;t_Uzj$UVc*TT-i#$EPTRq)@(L76>urgitcVn4BtlwZnI-8tKSFD=%B zJ;3V+FrX7->b{Ec$o7s$Xcw-_PYvW%(t8!DsF84=!qFz&2E3}`6M9u=75ZG`7j14G A00000 literal 0 HcmV?d00001 diff --git a/ini/ini.d/real16le.conf b/ini/ini.d/real16le.conf new file mode 100644 index 0000000000000000000000000000000000000000..83038bafb04b3f6dc3f14be58791ca4aba4ec215 GIT binary patch literal 3288 zcmc(hTW=FF5QXPCzry0B5^A#z1%!$aib@ekEmTb(kPwP;DQ%!hqijOyp9j7(j<dUI z(r|e|t4+N2%$f0-i~aLQW|;*$vr8LT&M5wN7)|WlI(EhAGqYEG1-oH1MK&ONZ9|{y z`AFjtYq`~UKAL7nu6bdfnEA%~gw=u12YUg=uGOvK@|iv4$y{^j60&oRhIISr<{(bc z9y4FYIIc(sJMeFLd|@**It%$47+vOab~|w2ulbtdhkR+^O(D_5W*=?Y6)TdMv7do` zw|#sN>Ls%o`|2Q<!Os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UX{^Rsty{<DA|_dp%^vrZo|#Ijeren-~k zIL*9g*&Ck)p9JRa*V5<6+8lG=#`K;4_I;c=ZNT`?U<7lW%wg_pZN9d)W`lz|UIyy> zBzO^za$nl<;Z5=zn4jjcEvIsNKj(4zA?WW0zS=Vv8S6V7>EYi;Y}nV9UgENogFC&( zX=J^ciV1!nZ|n1;?B5F>1oPfJ&zyaE(!?E=Grry>e2j6yX#|b`C}W)2RkQw%<#Pm^ zc-iZH70;Yb;^067^AVUg{;uy0PIBV|H^0gG<ZIcRA7|}2pwVe?Ct%A?&T88J!j&Jo z*dIalxRo(G*rg`o?0UzqTPv~r_QG8*YFlka#@p(&t-juX>UlR~?-VUZKnHPXrhc1# z&sV?p9FA<);<i`TY&M<u?{)8+dTr9ce*26*SBc;EkRQKm^^N>D@wy79*6b?%yotvM z$Lgt0dVBs3&g=4D<fu;j+`F4OuU@#}%2p5Q6}{;<LhmaLj7QL%U(1+}{=d#!)BIMx z_V)GNc>W)Ro+DVsI?kGyIQyOijittY@6?&U<|8NL-nsh4eN4dL-xc%Q0l&u9-VL4w zBhY{B-U*I^5y+YShk?BNF6d=k+kd-qYK#$E;M<z-8p_+5Id}6B?2^M9Ik(J1-SyS; zpns!`M^FuE>Wuz)96SwPmiy2*8@KkfJn&Q#^}&4v^6C4f*3Nj7?5o>0yOI4@gMRtx zof5mc@?$=N>PPq9Aw9hf{NlW;Z*jNz>)w*D-o71Nm#@6^D;{gyx5e3&`@drR1H9iI A00000 literal 0 HcmV?d00001 diff --git a/ini/ini.d/real32le.conf b/ini/ini.d/real32le.conf new file mode 100644 index 0000000000000000000000000000000000000000..453a2ad25f09b28f18a1cef08b61cedac6cb9996 GIT binary patch literal 6576 zcmdtmTWeia6b0Zs`zsc{2*oDV)*^~Xh!qQ|ElnN-2@<tlV^iw=&#U9ZGhnmX=k%Ne zB=|7c>o(^cbIiF`PW$&?dwU0a|6=5O8hjUgAN(AQ+4y|5_A=jRf%(O1?VEhrncEw| z?}4>n0)9up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v;L0da|G*n z+3S53&zw%;;6MZO5tujrw(kv2a^nLxzsdRJYu=k5XYDYc(Mj+iV9QR<YTEw7l^?p; zA3^oFn=w1srY7QSd&jR^E3y3c!d)(ETWv<ho9eWwzTSZ9`7mSe6fH+U2XSboe(QeE zSHJcgj%=6WwpW&H)}8n7b?=*ct<%7M`;0zUiQo5-AHQq$jr`Z~x(cV(>?-}dj>ibc z>Zwk8d-@Je>+)aZs7|}wyE{3rUbx}PRuAbFz3DeX?<)<AN6?(#$e54*zs}pM`Q3c& z?drSn{67diM=+0dm^CqR_B{$3OO5;9sWX4gM^47QbM=e+SOI^3SIqAP{2E((H+T_@ zK>xA39~=ZDkTd%a19|sd(95{C|F-4S7$dg8w>94-l(#ce?&c%dCWqTOH_t=e_0`Lu zf1`{?Pz`D7jQ%(eo(DJOKJ?ATtvxLdJk>;fa36tu`hKakGu|Zo>bA*lWdHS`Uw(S0 y#ICOVn2(_P(Y<#_Pj3RhIB)A)+)e(vH|MLj?*-T8D=+<u#}fBVakk|?kMR!??;QXD literal 0 HcmV?d00001 diff --git a/ini/ini.d/real8.conf b/ini/ini.d/real8.conf new file mode 100644 index 0000000..a379f5d --- /dev/null +++ b/ini/ini.d/real8.conf @@ -0,0 +1,70 @@ +// This is a real file with some comments + +[config] +version = 0.1 + +/**/ +[monitor] +description = Monitor Configuration +sbusTimeout = 10 +sbusAddress = unix:path=/var/lib/sss/pipes/private/dbus +servicePingTime = 10 +bad_number = 5a + +/* Service section defines + * which service are allowed. + */ +[services] +description = Local service configuration +activeServices = dp, nss, pam, info + +[services/dp] +description = Data Provider Configuration +command = /usr/libexec/sssd/sssd_dp + +[services/nss] +description = NSS Responder Configuration +unixSocket = /var/lib/sss/pipes/nss +command = /usr/libexec/sssd/sssd_nss + +[services/pam] +command = /usr/libexec/sssd/sssd_pam +description = PAM Responder Configuration +unixSocket = /var/lib/sss/pipes/pam + +[services/info] +description = InfoPipe Configuration +command = ./sbin/sssd_info + +[domains] +domainsOrder = , LOCAL, , EXAMPLE.COM, , SOMEOTHER.COM , , +badarray = , , , , , +somearray = , +someotherarray = , ; +justdelim=:;,; +yetanother = + +[domains/LOCAL] +description = Reserved domain for local configurations +legacy = FALSE +enumerate = 3 + +[domains/EXAMPLE.COM] +description = Example domain served by IPA +provider = ipa +server = ipaserver1.example.com +server = ipabackupserver.example.com +legacy = FALSE +server = otheripabackupserver.example.com +enumerate = 0 +binary_test = '010203' +binary_test_two = '0A0b0C' +long_array = 1 2; 4' ;8p .16/ 32? +double_array = 1.1 2.222222; .4' . ;8p .16/ -32? +server = yetanotheripabackupserver.example.com +empty_value = +space_value = " " +int32_t = -1000000000 +uint32_t = 3000000000 +int64_t = -1000000000123 +uint64_t = 3000000000123 diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c index 3a523af..6e98eb5 100644 --- a/ini/ini_parse_ut.c +++ b/ini/ini_parse_ut.c @@ -181,6 +181,11 @@ int read_save_test(void) "ipa", "test", "smerge", + "real8", + "real16be", + "real16le", + "real32be", + "real32le", NULL }; INIOUT(printf("<==== Read save test ====>\n")); @@ -215,6 +220,11 @@ int read_again_test(void) "ipa", "test", "smerge", + "real8", + "real16be", + "real16le", + "real32be", + "real32le", NULL }; INIOUT(printf("<==== Read again test ====>\n")); @@ -3010,6 +3020,28 @@ int comment_test(void) return EOK; } +void create_boms(void) +{ + FILE *f; + + f = fopen("bom2be","wb"); + fprintf(f,"%c%c", 0xFE, 0xFF); + fclose(f); + f = fopen("bom2le","wb"); + fprintf(f,"%c%c", 0xFF, 0xFE); + fclose(f); + f = fopen("bom4be","wb"); + fprintf(f,"%c%c%c%c", 0x00, 0x00, 0xFE, 0xFF); + fclose(f); + f = fopen("bom4le","wb"); + fprintf(f,"%c%c%c%c", 0xFF, 0xFE, 0x00, 0x00); + fclose(f); + f = fopen("bom3","wb"); + fprintf(f,"%c%c%c", 0xEF, 0xBB, 0xBF); + fclose(f); +} + + /* Main function of the unit test */ int main(int argc, char *argv[]) { @@ -3036,6 +3068,9 @@ int main(int argc, char *argv[]) if (var) verbose = 1; } + /* Create boms in case we want to create more test files */ + create_boms(); + INIOUT(printf("Start\n")); while ((t = tests[i++])) { -- 1.7.1
From f0c79c9091d9165d60aaa030d09fe63450215c5d Mon Sep 17 00:00:00 2001 From: Dmitri Pal <d...@redhat.com> Date: Wed, 9 Oct 2013 23:31:49 -0400 Subject: [PATCH 2/4] [INI] Extend internal file handle When we need to decode the file we need to keep it in memory so we need to have a buffer. Adding simple buffer into the internal structure. --- ini/ini_config_priv.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/ini/ini_config_priv.h b/ini/ini_config_priv.h index 89ad8a9..e1292f7 100644 --- a/ini/ini_config_priv.h +++ b/ini/ini_config_priv.h @@ -26,6 +26,7 @@ #include <sys/stat.h> #include <unistd.h> #include "collection.h" +#include "simplebuffer.h" #include "ini_comment.h" /* Configuration object */ @@ -71,6 +72,8 @@ struct ini_cfgfile { struct stat file_stats; /* Were stats read ? */ int stats_read; + /* Internal buffer */ + struct simplebuffer *file_data; }; /* Parsing error */ -- 1.7.1
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel