diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-12 12:16:21 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-12 12:16:21 +0000 |
commit | 5c3299300905698c45d1ace64a61a431312993a4 (patch) | |
tree | f89cb98e77ed897e29dd7993693c5cf0433ccb82 | |
parent | f8de411e2428b9c8878a8be3602f022812a3ab70 (diff) | |
download | busybox-w32-5c3299300905698c45d1ace64a61a431312993a4.tar.gz busybox-w32-5c3299300905698c45d1ace64a61a431312993a4.tar.bz2 busybox-w32-5c3299300905698c45d1ace64a61a431312993a4.zip |
mount: users report that CIFS support is breaking things,
mostly remove it.
-rw-r--r-- | networking/dnsd.c | 188 | ||||
-rw-r--r-- | util-linux/mount.c | 19 |
2 files changed, 104 insertions, 103 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c index 78054ed85..5dbaec1eb 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -136,17 +136,18 @@ static struct dns_entry *parse_conf_file(const char *fileconf) | |||
136 | 136 | ||
137 | /* | 137 | /* |
138 | * Look query up in dns records and return answer if found. | 138 | * Look query up in dns records and return answer if found. |
139 | * qs is the query string. | ||
140 | */ | 139 | */ |
141 | static int table_lookup(uint8_t *as, struct dns_entry *d, uint16_t type, uint8_t *qs) | 140 | static char *table_lookup(struct dns_entry *d, |
141 | uint16_t type, | ||
142 | char* query_string) | ||
142 | { | 143 | { |
143 | while (d) { | 144 | while (d) { |
144 | unsigned len = d->name[0]; | 145 | unsigned len = d->name[0]; |
145 | /* d->name[len] is the last (non NUL) char */ | 146 | /* d->name[len] is the last (non NUL) char */ |
146 | #if DEBUG | 147 | #if DEBUG |
147 | char *p, *q; | 148 | char *p, *q; |
148 | q = (char *)&(qs[1]); | 149 | q = query_string + 1; |
149 | p = &(d->name[1]); | 150 | p = d->name + 1; |
150 | fprintf(stderr, "%d/%d p:%s q:%s %d\n", | 151 | fprintf(stderr, "%d/%d p:%s q:%s %d\n", |
151 | (int)strlen(p), len, | 152 | (int)strlen(p), len, |
152 | p, q, (int)strlen(q) | 153 | p, q, (int)strlen(q) |
@@ -155,31 +156,40 @@ static int table_lookup(uint8_t *as, struct dns_entry *d, uint16_t type, uint8_t | |||
155 | if (type == htons(REQ_A)) { | 156 | if (type == htons(REQ_A)) { |
156 | /* search by host name */ | 157 | /* search by host name */ |
157 | if (len != 1 || d->name[1] != '*') { | 158 | if (len != 1 || d->name[1] != '*') { |
158 | if (strcasecmp(d->name, (char*)qs) != 0) | 159 | /* we are lax, hope no name component is ever >64 so that length |
160 | * (which will be represented as 'A','B'...) matches a lowercase letter. | ||
161 | * Actually, I think false matches are hard to construct. | ||
162 | * Example. | ||
163 | * [31] len is represented as '1', [65] as 'A', [65+32] as 'a'. | ||
164 | * [65] <65 same chars>[31]<31 same chars>NUL | ||
165 | * [65+32]<65 same chars>1 <31 same chars>NUL | ||
166 | * This example seems to be the minimal case when false match occurs. | ||
167 | */ | ||
168 | if (strcasecmp(d->name, query_string) != 0) | ||
159 | goto next; | 169 | goto next; |
160 | } | 170 | } |
161 | move_to_unaligned32((uint32_t *)as, d->ip); | 171 | return (char *)&d->ip; |
162 | #if DEBUG | 172 | #if DEBUG |
163 | fprintf(stderr, "OK as:%x\n", (int)d->ip); | 173 | fprintf(stderr, "Found IP:%x\n", (int)d->ip); |
164 | #endif | 174 | #endif |
165 | return 0; | 175 | return 0; |
166 | } | 176 | } |
167 | /* search by IP-address */ | 177 | /* search by IP-address */ |
168 | if ((len != 1 || d->name[1] != '*') | 178 | if ((len != 1 || d->name[1] != '*') |
169 | /* assume (do not check) that qs ends in ".in-addr.arpa" */ | 179 | /* we assume (do not check) that query_string |
170 | && strncmp(d->rip, (char*)qs, strlen(d->rip)) == 0 | 180 | * ends in ".in-addr.arpa" */ |
181 | && strncmp(d->rip, query_string, strlen(d->rip)) == 0 | ||
171 | ) { | 182 | ) { |
172 | strcpy((char *)as, d->name); | ||
173 | #if DEBUG | 183 | #if DEBUG |
174 | fprintf(stderr, "OK as:%s\n", as); | 184 | fprintf(stderr, "Found name:%s\n", d->name); |
175 | #endif | 185 | #endif |
176 | return 0; | 186 | return d->name; |
177 | } | 187 | } |
178 | next: | 188 | next: |
179 | d = d->next; | 189 | d = d->next; |
180 | } | 190 | } |
181 | 191 | ||
182 | return -1; | 192 | return NULL; |
183 | } | 193 | } |
184 | 194 | ||
185 | /* | 195 | /* |
@@ -193,12 +203,11 @@ That is, the bit labeled 0 is the most significant bit. | |||
193 | ... | 203 | ... |
194 | 204 | ||
195 | 4.1.1. Header section format | 205 | 4.1.1. Header section format |
196 | 1 1 1 1 1 1 | 206 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
197 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | ||
198 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 207 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
199 | | ID | | 208 | | ID | |
200 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 209 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
201 | |QR| OPCODE |AA|TC|RD|RA| Z | RCODE | | 210 | |QR| OPCODE |AA|TC|RD|RA| 0 0 0| RCODE | |
202 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 211 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
203 | | QDCOUNT | | 212 | | QDCOUNT | |
204 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 213 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
@@ -208,20 +217,18 @@ That is, the bit labeled 0 is the most significant bit. | |||
208 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 217 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
209 | | ARCOUNT | | 218 | | ARCOUNT | |
210 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 219 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
211 | ID 16 bit random identifier assigned by query. | 220 | ID 16 bit random identifier assigned by querying peer. |
212 | Used to match query/response. | 221 | Used to match query/response. |
213 | QR message is a query (0), or a response (1). | 222 | QR message is a query (0), or a response (1). |
214 | OPCODE 0 standard query (QUERY) | 223 | OPCODE 0 standard query (QUERY) |
215 | 1 inverse query (IQUERY) | 224 | 1 inverse query (IQUERY) |
216 | 2 server status request (STATUS) | 225 | 2 server status request (STATUS) |
217 | AA Authoritative Answer - this bit is valid in responses, | 226 | AA Authoritative Answer - this bit is valid in responses. |
218 | and specifies that the responding name server is an | 227 | Responding name server is an authority for the domain name |
219 | authority for the domain name in question section. | 228 | in question section. Answer section may have multiple owner names |
220 | Note that the contents of the answer section may have | 229 | because of aliases. The AA bit corresponds to the name which matches |
221 | multiple owner names because of aliases. The AA bit | 230 | the query name, or the first owner name in the answer section. |
222 | corresponds to the name which matches the query name, or | 231 | TC TrunCation - this message was truncated. |
223 | the first owner name in the answer section. | ||
224 | TC TrunCation - specifies that this message was truncated. | ||
225 | RD Recursion Desired - this bit may be set in a query and | 232 | RD Recursion Desired - this bit may be set in a query and |
226 | is copied into the response. If RD is set, it directs | 233 | is copied into the response. If RD is set, it directs |
227 | the name server to pursue the query recursively. | 234 | the name server to pursue the query recursively. |
@@ -229,30 +236,25 @@ RD Recursion Desired - this bit may be set in a query and | |||
229 | RA Recursion Available - this be is set or cleared in a | 236 | RA Recursion Available - this be is set or cleared in a |
230 | response, and denotes whether recursive query support is | 237 | response, and denotes whether recursive query support is |
231 | available in the name server. | 238 | available in the name server. |
232 | Z Reserved for future use. Must be zero. | ||
233 | RCODE Response code. | 239 | RCODE Response code. |
234 | 0 No error condition | 240 | 0 No error condition |
235 | 1 Format error | 241 | 1 Format error |
236 | 2 Server failure - The name server was | 242 | 2 Server failure - server was unable to process the query |
237 | unable to process this query due to a | 243 | due to a problem with the name server. |
238 | problem with the name server. | 244 | 3 Name Error - meaningful only for responses from |
239 | 3 Name Error - Meaningful only for | 245 | an authoritative name server. The referenced domain name |
240 | responses from an authoritative name | 246 | does not exist. |
241 | server, this code signifies that the | ||
242 | domain name referenced in the query does | ||
243 | not exist. | ||
244 | 4 Not Implemented. | 247 | 4 Not Implemented. |
245 | 5 Refused. | 248 | 5 Refused. |
246 | QDCOUNT number of entries in the question section. | 249 | QDCOUNT number of entries in the question section. |
247 | ANCOUNT number of resource records in the answer section. | 250 | ANCOUNT number of records in the answer section. |
248 | NSCOUNT number of name server resource records in the authority records section. | 251 | NSCOUNT number of records in the authority records section. |
249 | ARCOUNT number of resource records in the additional records section. | 252 | ARCOUNT number of records in the additional records section. |
250 | 253 | ||
251 | 4.1.2. Question section format | 254 | 4.1.2. Question section format |
252 | 255 | ||
253 | The section contains QDCOUNT (usually 1) entries, each of the following format: | 256 | The section contains QDCOUNT (usually 1) entries, each of this format: |
254 | 1 1 1 1 1 1 | 257 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
255 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | ||
256 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 258 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
257 | / QNAME / | 259 | / QNAME / |
258 | / / | 260 | / / |
@@ -296,12 +298,11 @@ QCLASS a two octet code that specifies the class of the query. | |||
296 | 298 | ||
297 | 4.1.3. Resource record format | 299 | 4.1.3. Resource record format |
298 | 300 | ||
299 | The answer, authority, and additional sections all share the same | 301 | The answer, authority, and additional sections all share the same format: |
300 | format: a variable number of resource records, where the number of | 302 | a variable number of resource records, where the number of records |
301 | records is specified in the corresponding count field in the header. | 303 | is specified in the corresponding count field in the header. |
302 | Each resource record has the following format: | 304 | Each resource record has this format: |
303 | 1 1 1 1 1 1 | 305 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
304 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | ||
305 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 306 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
306 | / / | 307 | / / |
307 | / NAME / | 308 | / NAME / |
@@ -320,30 +321,21 @@ Each resource record has the following format: | |||
320 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 321 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
321 | NAME a domain name to which this resource record pertains. | 322 | NAME a domain name to which this resource record pertains. |
322 | TYPE two octets containing one of the RR type codes. This | 323 | TYPE two octets containing one of the RR type codes. This |
323 | field specifies the meaning of the data in the RDATA | 324 | field specifies the meaning of the data in the RDATA field. |
324 | field. | 325 | CLASS two octets which specify the class of the data in the RDATA field. |
325 | CLASS two octets which specify the class of the data in the | 326 | TTL a 32 bit unsigned integer that specifies the time interval |
326 | RDATA field. | 327 | (in seconds) that the record may be cached. |
327 | TTL a 32 bit unsigned integer that specifies the time | 328 | RDLENGTH a 16 bit integer, length in octets of the RDATA field. |
328 | interval (in seconds) that the resource record may be | 329 | RDATA a variable length string of octets that describes the resource. |
329 | cached before it should be discarded. Zero values are | 330 | The format of this information varies according to the TYPE |
330 | interpreted to mean that the RR can only be used for the | 331 | and CLASS of the resource record. |
331 | transaction in progress, and should not be cached. | 332 | If the TYPE is A and the CLASS is IN, it's a 4 octet IP address. |
332 | RDLENGTH an unsigned 16 bit integer that specifies the length in | ||
333 | octets of the RDATA field. | ||
334 | RDATA a variable length string of octets that describes the | ||
335 | resource. The format of this information varies | ||
336 | according to the TYPE and CLASS of the resource record. | ||
337 | For example, if the TYPE is A and the CLASS is IN, | ||
338 | the RDATA field is a 4 octet ARPA Internet address. | ||
339 | 333 | ||
340 | 4.1.4. Message compression | 334 | 4.1.4. Message compression |
341 | 335 | ||
342 | In order to reduce the size of messages, the domain system utilizes a | 336 | In order to reduce the size of messages, domain names coan be compressed. |
343 | compression scheme which eliminates the repetition of domain names in a | 337 | An entire domain name or a list of labels at the end of a domain name |
344 | message. In this scheme, an entire domain name or a list of labels at | 338 | is replaced with a pointer to a prior occurance of the same name. |
345 | the end of a domain name is replaced with a pointer to a prior occurance | ||
346 | of the same name. | ||
347 | 339 | ||
348 | The pointer takes the form of a two octet sequence: | 340 | The pointer takes the form of a two octet sequence: |
349 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | 341 | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
@@ -355,27 +347,26 @@ labels are restricted to 63 octets or less. The OFFSET field specifies | |||
355 | an offset from the start of the message (i.e., the first octet | 347 | an offset from the start of the message (i.e., the first octet |
356 | of the ID field in the domain header). | 348 | of the ID field in the domain header). |
357 | A zero offset specifies the first byte of the ID field, etc. | 349 | A zero offset specifies the first byte of the ID field, etc. |
358 | 350 | Domain name in a message can be represented as either: | |
359 | The compression scheme allows a domain name in a message to be | ||
360 | represented as either: | ||
361 | - a sequence of labels ending in a zero octet | 351 | - a sequence of labels ending in a zero octet |
362 | - a pointer | 352 | - a pointer |
363 | - a sequence of labels ending with a pointer | 353 | - a sequence of labels ending with a pointer |
364 | */ | 354 | */ |
365 | static int process_packet(struct dns_entry *conf_data, uint32_t conf_ttl, uint8_t *buf) | 355 | static int process_packet(struct dns_entry *conf_data, |
356 | uint32_t conf_ttl, | ||
357 | uint8_t *buf) | ||
366 | { | 358 | { |
367 | uint8_t answstr[MAX_NAME_LEN + 1]; | 359 | char *answstr; |
368 | struct dns_head *head; | 360 | struct dns_head *head; |
369 | struct dns_prop *unaligned_qprop; | 361 | struct dns_prop *unaligned_qprop; |
370 | uint8_t *from, *answb; | 362 | char *query_string; |
363 | uint8_t *answb; | ||
371 | uint16_t outr_rlen; | 364 | uint16_t outr_rlen; |
372 | uint16_t outr_flags; | 365 | uint16_t outr_flags; |
373 | uint16_t type; | 366 | uint16_t type; |
374 | uint16_t class; | 367 | uint16_t class; |
375 | int querystr_len; | 368 | int querystr_len; |
376 | 369 | ||
377 | answstr[0] = '\0'; | ||
378 | |||
379 | head = (struct dns_head *)buf; | 370 | head = (struct dns_head *)buf; |
380 | if (head->nquer == 0) { | 371 | if (head->nquer == 0) { |
381 | bb_error_msg("packet has 0 queries, ignored"); | 372 | bb_error_msg("packet has 0 queries, ignored"); |
@@ -388,15 +379,15 @@ static int process_packet(struct dns_entry *conf_data, uint32_t conf_ttl, uint8_ | |||
388 | } | 379 | } |
389 | 380 | ||
390 | /* start of query string */ | 381 | /* start of query string */ |
391 | from = (void *)(head + 1); | 382 | query_string = (void *)(head + 1); |
392 | /* caller guarantees strlen is <= MAX_PACK_LEN */ | 383 | /* caller guarantees strlen is <= MAX_PACK_LEN */ |
393 | querystr_len = strlen((char *)from) + 1; | 384 | querystr_len = strlen(query_string) + 1; |
394 | /* may be unaligned! */ | 385 | /* may be unaligned! */ |
395 | unaligned_qprop = (void *)(from + querystr_len); | 386 | unaligned_qprop = (void *)(query_string + querystr_len); |
387 | querystr_len += sizeof(unaligned_qprop); | ||
396 | /* where to append answer block */ | 388 | /* where to append answer block */ |
397 | answb = (void *)(unaligned_qprop + 1); | 389 | answb = (void *)(unaligned_qprop + 1); |
398 | 390 | ||
399 | outr_rlen = 0; | ||
400 | /* QR = 1 "response", RCODE = 4 "Not Implemented" */ | 391 | /* QR = 1 "response", RCODE = 4 "Not Implemented" */ |
401 | outr_flags = htons(0x8000 | 4); | 392 | outr_flags = htons(0x8000 | 4); |
402 | 393 | ||
@@ -414,29 +405,29 @@ static int process_packet(struct dns_entry *conf_data, uint32_t conf_ttl, uint8_ | |||
414 | goto empty_packet; | 405 | goto empty_packet; |
415 | } | 406 | } |
416 | 407 | ||
417 | bb_info_msg("%s", (char *)from); | 408 | /* look up the name */ |
418 | if (table_lookup(answstr, conf_data, type, from) != 0) { | 409 | #if DEBUG |
410 | /* need to convert lengths to dots before we can use it in non-debug */ | ||
411 | bb_info_msg("%s", query_string); | ||
412 | #endif | ||
413 | answstr = table_lookup(conf_data, type, query_string); | ||
414 | outr_rlen = 4; | ||
415 | if (answstr && type == htons(REQ_PTR)) { | ||
416 | /* return a host name */ | ||
417 | outr_rlen = strlen(answstr) + 1; | ||
418 | } | ||
419 | if (!answstr | ||
420 | || (unsigned)(answb - buf) + querystr_len + 4 + 2 + outr_rlen > MAX_PACK_LEN | ||
421 | ) { | ||
419 | /* QR = 1 "response" | 422 | /* QR = 1 "response" |
420 | * AA = 1 "Authoritative Answer" | 423 | * AA = 1 "Authoritative Answer" |
421 | * RCODE = 3 "Name Error" */ | 424 | * RCODE = 3 "Name Error" */ |
422 | outr_flags = htons(0x8000 | 0x0400 | 3); | 425 | outr_flags = htons(0x8000 | 0x0400 | 3); |
423 | goto empty_packet; | 426 | goto empty_packet; |
424 | } | 427 | } |
425 | /* return an address */ | 428 | |
426 | outr_rlen = 4; | ||
427 | if (type == htons(REQ_PTR)) { | ||
428 | /* return a host name */ | ||
429 | outr_rlen = strlen((char *)answstr) + 1; | ||
430 | } | ||
431 | /* QR = 1 "response", | ||
432 | * AA = 1 "Authoritative Answer", | ||
433 | * RCODE = 0 "success" */ | ||
434 | outr_flags = htons(0x8000 | 0x0400 | 0); | ||
435 | /* we have one answer */ | ||
436 | head->nansw = htons(1); | ||
437 | /* copy query block to answer block */ | 429 | /* copy query block to answer block */ |
438 | querystr_len += sizeof(unaligned_qprop); | 430 | memcpy(answb, query_string, querystr_len); |
439 | memcpy(answb, from, querystr_len); | ||
440 | answb += querystr_len; | 431 | answb += querystr_len; |
441 | /* append answer Resource Record */ | 432 | /* append answer Resource Record */ |
442 | move_to_unaligned32((uint32_t *)answb, htonl(conf_ttl)); | 433 | move_to_unaligned32((uint32_t *)answb, htonl(conf_ttl)); |
@@ -446,6 +437,13 @@ static int process_packet(struct dns_entry *conf_data, uint32_t conf_ttl, uint8_ | |||
446 | memcpy(answb, answstr, outr_rlen); | 437 | memcpy(answb, answstr, outr_rlen); |
447 | answb += outr_rlen; | 438 | answb += outr_rlen; |
448 | 439 | ||
440 | /* QR = 1 "response", | ||
441 | * AA = 1 "Authoritative Answer", | ||
442 | * RCODE = 0 "success" */ | ||
443 | outr_flags = htons(0x8000 | 0x0400 | 0); | ||
444 | /* we have one answer */ | ||
445 | head->nansw = htons(1); | ||
446 | |||
449 | empty_packet: | 447 | empty_packet: |
450 | head->flags |= outr_flags; | 448 | head->flags |= outr_flags; |
451 | head->nauth = head->nadd = 0; | 449 | head->nauth = head->nadd = 0; |
diff --git a/util-linux/mount.c b/util-linux/mount.c index d647c71b1..694057bbe 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -419,12 +419,12 @@ static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts) | |||
419 | int errno_save = errno; | 419 | int errno_save = errno; |
420 | args[0] = xasprintf("mount.%s", mp->mnt_type); | 420 | args[0] = xasprintf("mount.%s", mp->mnt_type); |
421 | rc = 1; | 421 | rc = 1; |
422 | args[rc++] = mp->mnt_fsname; | ||
423 | args[rc++] = mp->mnt_dir; | ||
422 | if (filteropts) { | 424 | if (filteropts) { |
423 | args[rc++] = (char *)"-o"; | 425 | args[rc++] = (char *)"-o"; |
424 | args[rc++] = filteropts; | 426 | args[rc++] = filteropts; |
425 | } | 427 | } |
426 | args[rc++] = mp->mnt_fsname; | ||
427 | args[rc++] = mp->mnt_dir; | ||
428 | args[rc] = NULL; | 428 | args[rc] = NULL; |
429 | rc = wait4pid(spawn(args)); | 429 | rc = wait4pid(spawn(args)); |
430 | free(args[0]); | 430 | free(args[0]); |
@@ -1605,22 +1605,24 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1605 | && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\') | 1605 | && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\') |
1606 | && mp->mnt_fsname[0] == mp->mnt_fsname[1] | 1606 | && mp->mnt_fsname[0] == mp->mnt_fsname[1] |
1607 | ) { | 1607 | ) { |
1608 | #if 0 /* reported to break things */ | ||
1608 | len_and_sockaddr *lsa; | 1609 | len_and_sockaddr *lsa; |
1609 | char *ip, *dotted; | 1610 | char *ip, *dotted; |
1610 | char *s; | 1611 | char *s; |
1611 | 1612 | ||
1612 | rc = 1; | ||
1613 | // Replace '/' with '\' and verify that unc points to "//server/share". | 1613 | // Replace '/' with '\' and verify that unc points to "//server/share". |
1614 | for (s = mp->mnt_fsname; *s; ++s) | 1614 | for (s = mp->mnt_fsname; *s; ++s) |
1615 | if (*s == '/') *s = '\\'; | 1615 | if (*s == '/') *s = '\\'; |
1616 | 1616 | ||
1617 | // Get server IP | 1617 | // Get server IP |
1618 | s = strrchr(mp->mnt_fsname, '\\'); | 1618 | s = strrchr(mp->mnt_fsname, '\\'); |
1619 | if (s <= mp->mnt_fsname+1) goto report_error; | 1619 | if (s <= mp->mnt_fsname+1) |
1620 | goto report_error; | ||
1620 | *s = '\0'; | 1621 | *s = '\0'; |
1621 | lsa = host2sockaddr(mp->mnt_fsname+2, 0); | 1622 | lsa = host2sockaddr(mp->mnt_fsname+2, 0); |
1622 | *s = '\\'; | 1623 | *s = '\\'; |
1623 | if (!lsa) goto report_error; | 1624 | if (!lsa) |
1625 | goto report_error; | ||
1624 | 1626 | ||
1625 | // Insert ip=... option into string flags. | 1627 | // Insert ip=... option into string flags. |
1626 | dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); | 1628 | dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); |
@@ -1630,18 +1632,19 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1630 | // Compose new unc '\\server-ip\share' | 1632 | // Compose new unc '\\server-ip\share' |
1631 | // (s => slash after hostname) | 1633 | // (s => slash after hostname) |
1632 | mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); | 1634 | mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); |
1633 | 1635 | #endif | |
1634 | // Lock is required | 1636 | // Lock is required [why?] |
1635 | vfsflags |= MS_MANDLOCK; | 1637 | vfsflags |= MS_MANDLOCK; |
1636 | |||
1637 | mp->mnt_type = (char*)"cifs"; | 1638 | mp->mnt_type = (char*)"cifs"; |
1638 | rc = mount_it_now(mp, vfsflags, filteropts); | 1639 | rc = mount_it_now(mp, vfsflags, filteropts); |
1640 | #if 0 | ||
1639 | if (ENABLE_FEATURE_CLEAN_UP) { | 1641 | if (ENABLE_FEATURE_CLEAN_UP) { |
1640 | free(mp->mnt_fsname); | 1642 | free(mp->mnt_fsname); |
1641 | free(ip); | 1643 | free(ip); |
1642 | free(dotted); | 1644 | free(dotted); |
1643 | free(lsa); | 1645 | free(lsa); |
1644 | } | 1646 | } |
1647 | #endif | ||
1645 | goto report_error; | 1648 | goto report_error; |
1646 | } | 1649 | } |
1647 | 1650 | ||